调整订单生成函数

This commit is contained in:
liaofei 2019-11-19 10:18:52 +08:00
parent 94aa866810
commit 57a97873b9
3 changed files with 19 additions and 11 deletions

View File

@ -46,10 +46,6 @@ class StoreProductController
* @param Request $request * @param Request $request
* @param $id * @param $id
* @return mixed * @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function code(Request $request, $id) public function code(Request $request, $id)
{ {
@ -103,6 +99,17 @@ class StoreProductController
} }
} }
/**
* 产品详情
* @param Request $request
* @param $id
* @param int $type
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function detail(Request $request, $id,$type = 0) public function detail(Request $request, $id,$type = 0)
{ {
if (!$id || !($storeInfo = StoreProduct::getValidProduct($id))) return app('json')->fail('商品不存在或已下架'); if (!$id || !($storeInfo = StoreProduct::getValidProduct($id))) return app('json')->fail('商品不存在或已下架');
@ -167,7 +174,7 @@ class StoreProductController
$data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : []; $data['system_store'] = ($res = SystemStore::getStoreDispose()) ? $res : [];
$data['good_list'] = StoreProduct::getGoodList(18,'image,store_name,price,id,ot_price'); $data['good_list'] = StoreProduct::getGoodList(18,'image,store_name,price,id,ot_price');
$data['mapKey'] = sysConfig('tengxun_map_key'); $data['mapKey'] = sysConfig('tengxun_map_key');
$data['store_self_mention']= (int)sysConfig('store_self_mention') ?? 0;//门店自提是否开启 $data['store_self_mention'] = (int)sysConfig('store_self_mention') ?? 0;//门店自提是否开启
return app('json')->successful($data); return app('json')->successful($data);
} }

View File

@ -335,7 +335,7 @@ class StoreOrder extends BaseModel
} }
$orderInfo = [ $orderInfo = [
'uid' => $uid, 'uid' => $uid,
'order_id' => $test ? 0 : self::getNewOrderId($uid), 'order_id' => $test ? 0 : self::getNewOrderId(),
'real_name' => $addressInfo['real_name'], 'real_name' => $addressInfo['real_name'],
'user_phone' => $addressInfo['phone'], 'user_phone' => $addressInfo['phone'],
'user_address' => $addressInfo['province'] . ' ' . $addressInfo['city'] . ' ' . $addressInfo['district'] . ' ' . $addressInfo['detail'], 'user_address' => $addressInfo['province'] . ' ' . $addressInfo['city'] . ' ' . $addressInfo['district'] . ' ' . $addressInfo['detail'],
@ -490,10 +490,10 @@ class StoreOrder extends BaseModel
* @param $uid 用户uid * @param $uid 用户uid
* @return string * @return string
*/ */
public static function getNewOrderId($uid) public static function getNewOrderId()
{ {
list($msec, $sec) = explode(' ', microtime()); list($msec, $sec) = explode(' ', microtime());
$msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000); $msectime = number_format((floatval($msec) + floatval($sec)) * 1000,0,'','');
$orderId = 'wx' . $msectime . mt_rand(10000,99999); $orderId = 'wx' . $msectime . mt_rand(10000,99999);
if(self::be(['order_id'=>$orderId])) $orderId = 'wx' . $msectime . mt_rand(10000,99999); if(self::be(['order_id'=>$orderId])) $orderId = 'wx' . $msectime . mt_rand(10000,99999);
return $orderId; return $orderId;

View File

@ -133,8 +133,9 @@ class OrderSubscribe
//检测会员等级 //检测会员等级
event('UserLevelAfter', [$order['uid']]); event('UserLevelAfter', [$order['uid']]);
try{
//向后台发送新订单消息 //向后台发送新订单消息
ChannelService::instance()->send('NEW_ORDER', ['order_id'=>$order['order_id']]); ChannelService::instance()->send('NEW_ORDER', ['order_id'=>$order['order_id']]);
}catch (\Throwable $e){}
} }
} }