'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'order_id' => 'Order ID', 'give_score' => 'Give Score', 'give_coupon' => 'Give Coupon', 'give_currency' => 'Give Currency', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData($give_data, $order_id, $store_id, $mall_id) { if (empty($give_data)) return true; $model = new self(); $model->loadDefaultValues(); $give_score = 0; $give_coupon = []; $give_currency = []; foreach ($give_data as $item) { if ($item['type'] == 'score') { $give_score = $item['num']; } if ($item['type'] == 'coupon') { $give_coupon[] = $item; } } $model->give_score = $give_score; $model->give_coupon = json_encode($give_coupon); $model->give_currency = json_encode($give_currency); $model->order_id = $order_id; $model->store_id = $store_id; $model->mall_id = $mall_id; return $model->save(); } public static function give($mall_id, $user_id, $order_id, $store_id) { try { $order_give = self::findOne(['order_id' => $order_id, 'mall_id' => $mall_id]); if (empty($order_give)) return true; /*if (!empty($order_give['give_score'])) { $insert_wallet[] = [ 'mall_id' => $mall_id, 'user_id' => $user_id, 'is_frozen' => false, 'wallet_type' => 'score', 'money' => $order_give['give_score'], 'desc' => 'o2o订单支付赠送', 'source_table' => StoreOrder::tableName(), 'source_table_id' => $order_id, 'from_type' => UserWalletEnum::CONSUME, 'capital_type' => UserWalletEnum::CONSUME_ORDER_GIVE, ]; $res = UserWalletService::batchHandleByQueue($insert_wallet); if (empty($res)) throw new \Exception(UserWalletService::getStaticError()); }*/ $give_coupon = json_decode($order_give['give_coupon'], true); if (!empty($give_coupon)) { foreach ($give_coupon as $item) { StoreCouponUserRelate::giveCouponByOrder($mall_id, $store_id, $user_id, [$item['id']=>$item['num']], $item['from_type'], 2, 'o2o'); } } return true; } catch (\Exception $e) { self::setStaticError($e->getMessage()); return false; } } }