where(['id' => $id])->asArray()->one(); return $order; } public static function getByOrderSn($orderSn) { return xhOrder::find()->where(['orderSn' => $orderSn])->asArray()->one(); } public static function updateById($id, $data) { $re = xhOrder::updateById($id, $data); self::refresh($id); return $re; } public static function updateByCondition($condition, $data) { xhOrder::updateByCondition($condition, $data); } public static function refresh($id) { $cacheKey = configDict::getCacheKey('order') . $id; Yii::$app->redis->executeCommand('DEL', [$cacheKey]); self::getById($id); } public static function getAllByCondition($condition) { return xhOrder::find()->where($condition)->orderBy('createTime desc')->asArray()->all(); } /** * 付款订单 表单提交数据处理 * @param $payAdd * @param $post */ public static function formatPost(&$payAdd, $post) { $payAdd['actPrice'] = self::handle($post, 'consumeAmount', 0); $payAdd['receiveProvince'] = self::handle($post, 'province'); $payAdd['receiveCity'] = self::handle($post, 'city'); $payAdd['receiveDist'] = self::handle($post, 'receiveDist'); $payAdd['receiveAddress'] = self::handle($post, 'receiveAddress'); $payAdd['receiveFullAddress'] = self::handle($post, 'receiveFullAddress'); $payAdd['receiveFloor'] = self::handle($post, 'receiveFloor'); $payAdd['receiveLong'] = self::handle($post, 'receiveLong'); $payAdd['receiveLat'] = self::handle($post, 'receiveLat'); $payAdd['anonymity'] = (int)self::handle($post, 'anonymity', 0); //0不匿名派送 1匿名派送 $payAdd['sendCost'] = self::handle($post, 'sendCost', 0); //$payAdd['sendNum'] = self::handle($post, 'sendNum'); //配送编号,方便寻找订单对应的花, '')束 -- 不在这处理 $payAdd['sendDistance'] = self::handle($post, 'sendDistance', 0); $payAdd['reachTime'] = self::handle($post, 'reachTime', ''); $payAdd['reachPeriod'] = (int)self::handle($post, 'reachPeriod', 0); //0上午1下午2晚上,具体看配置文件 $payAdd['bookMobile'] = self::handle($post, 'bookMobile'); $payAdd['bookName'] = self::handle($post, 'bookName'); $payAdd['receiveMobile'] = self::handle($post, 'receiveMobile'); $payAdd['receiveUserName'] = self::handle($post, 'receiveUserName'); $payAdd['needCard'] = (int)self::handle($post, 'needCard', 0);//默认不要贺卡 $payAdd['needSend'] = (int)self::handle($post, 'needSend', 1);//默认要配送 $payAdd['blessing'] = self::handle($post, 'blessing'); $payAdd['remark'] = self::handle($post, 'remark'); $payAdd['uniCode'] = self::handle($post, 'uniCode'); //唯一号码,预留字段 $payAdd['luckyNum'] = self::handle($post, 'luckyNum', 0); //抽奖号码 $payAdd['printStatus'] = self::handle($post, 'printStatus', 0); $payAdd['status'] = self::handle($post, 'status', 0); //订单生存状态 0正常 1删除 $payAdd['orderName'] = self::handle($post, 'orderName'); //订单名称(商品名称) $payAdd['sourceType'] = self::handle($post, 'sourceType', 1); //订单来源,0商城订单 1付款订单 } /** * 默认值处理 与 数据校验 * @param $post * @param $key * @param string $default * @param string $checkType * @return string */ public static function handle($post, $key, $default = '', $checkType = '') { switch ($checkType) { case 'date': break; } return isset($post["$key"]) ? $post["$key"] : $default; } /** * 生成订单号 */ public static function generateOrderNo($merchantId, $userId) { return stringUtil::generateOrderNo($merchantId, $userId); } }