|
|
@@ -38,12 +38,9 @@ class Order extends Base
|
|
|
public function getLifeOrder(Request $request): Response
|
|
|
{
|
|
|
try {
|
|
|
- $param = $this->_valid([
|
|
|
- "order.require" => "请求参数错误",
|
|
|
- "code.require" => "请求参数错误"
|
|
|
- ],'post');
|
|
|
- if (!is_array($param)) return error($param);
|
|
|
- $sessionKey = (new Crypt)->config($this->getDyConfig())->getSessionKey($param['code']);
|
|
|
+ $param = $request->post();
|
|
|
+ print_r($param);
|
|
|
+ $sessionKey = (new Crypt)->config($this->getDyConfig())->getSessionKey($param['auth']);
|
|
|
if (empty($sessionKey)) return error("授权登录失败");
|
|
|
if (!isset($sessionKey['openid'])) return error("获取数据失败");
|
|
|
$openId = $sessionKey['openid'];
|
|
|
@@ -58,7 +55,15 @@ class Order extends Base
|
|
|
if ($user->isEmpty()) {
|
|
|
$userIn['id'] = $user->insertGetId($userIn);
|
|
|
}
|
|
|
- $order = (new SaasOrderLife)->where("order_id",$param['order'])->where("open_id",$openId)->findOrEmpty();
|
|
|
+ // 同步已经下单的订单
|
|
|
+ if (!empty($param['account'])) {
|
|
|
+ $this->asyncDyOrder($param['account'],$openId);
|
|
|
+ }
|
|
|
+ $order = (new SaasOrderLife)->where("open_id",$openId)->with(['goods' => function($query){
|
|
|
+ $query->field("out_id,product_img");
|
|
|
+ }])->append(['expire_at'])->withAttr(['expire_at' => function($data,$resp){
|
|
|
+ return date("Y-m-d",strtotime($resp['expire_at']));
|
|
|
+ }])->findOrEmpty();
|
|
|
if ($order->isEmpty()) return error("订单尚未同步");
|
|
|
return successTrans("success.data",[
|
|
|
"user" => get_object_vars((new AuthMode)->guard("member")->login($userIn)),
|
|
|
@@ -81,13 +86,18 @@ class Order extends Base
|
|
|
try {
|
|
|
$param = $this->_valid([
|
|
|
"order.require" => "请求参数错误",
|
|
|
- "location.require" => "请求参数错误"
|
|
|
+ "location.require" => "请求参数错误",
|
|
|
+ "keyword.default" => ""
|
|
|
],'post');
|
|
|
if (!is_array($param)) return error($param);
|
|
|
$order = (new SaasOrderLife)->where("order_id",$param['order'])->where("open_id",$request->user['open_id'])->findOrEmpty();
|
|
|
if ($order->isEmpty()) return error("订单尚未同步");
|
|
|
$location = explode(",",$param['location']);
|
|
|
- $resp = store_region($location[1],$location[0],2,"store_id={$order['store_id']} and agent_id={$order['agent_id']}");
|
|
|
+ $where = "store_id={$order['store_id']} and agent_id={$order['agent_id']}";
|
|
|
+ if (!empty($param['keyword'])) {
|
|
|
+ $where .= " and poi_name like '%".$param['keyword']."%'";
|
|
|
+ }
|
|
|
+ $resp = store_region($location[1],$location[0],2,$where);
|
|
|
foreach ($resp as $key=>$val) {
|
|
|
$resp[$key] = $val;
|
|
|
$resp[$key]['poi_id'] = (string) $val['poi_id'];
|