# Conflicts:
#	app/api/controller/order/OrderController.php
#	app/api/logic/order/OrderLogic.php
This commit is contained in:
luofei 2024-06-04 16:56:43 +08:00
commit 14bc0c1539
10 changed files with 26 additions and 42 deletions

View File

@ -20,7 +20,7 @@
$cid = $this->request->post('cid', 0);
$result = UploadService::image($cid);
return $this->success('上传成功', $result);
} catch (Exception $e) {
} catch (\Exception $e) {
return $this->fail($e->getMessage());
}
}

View File

@ -33,7 +33,8 @@ class UserController extends BaseApiController
if ($result === false) {
return $this->fail(UserLogic::getError());
}
return $this->success('绑定成功', [], 1, 1);
$data = UserLogic::info($this->userId);
return $this->success('绑定成功', $data, 1, 1);
}

View File

@ -28,9 +28,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array
{
return [
'=' => ['paid','status','source'],
'=' => ['paid','status'],
'between_time' => 'create_time',
'%like%' => ['number'],
'%like%' => ['order_id'],
];
}

View File

@ -41,9 +41,9 @@ class UserAddressList extends BaseAdminDataLists implements ListsSearchInterface
$user_id=$this->request->userId;
if(!$user_id) return [];
return UserAddress::where($this->searchWhere)->where('uid',$user_id)
->field('address_id,real_name,detail,phone,is_default')
->field('id address_id,real_name,detail,phone,is_default')
->limit($this->limitOffset, $this->limitLength)
->order(['address_id' => 'desc'])
->order(['id' => 'desc'])
->select()
->toArray();
}

View File

@ -25,7 +25,7 @@ use app\common\service\{
};
use app\common\model\user\{User, UserAuth};
use app\common\service\wechat\WeChatMnpService;
use think\facade\Db;
use Webman\Config;
/**
@ -221,7 +221,7 @@ class LoginLogic extends BaseLogic
*/
public static function mnpLogin(array $params)
{
Db::startTrans();
// Db::startTrans();
try {
//通过code获取微信 openid
$response = (new WeChatMnpService())->getMnpResByCode($params['code']);
@ -229,21 +229,11 @@ class LoginLogic extends BaseLogic
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
// 更新登录信息
self::updateLoginInfo($userInfo['id']);
//判断是不是员工
// $userInfo['is_staff'] = 0;
// $userInfo['store_id'] = 0;
// if(isset($userInfo['mobile']) && $userInfo['mobile']){
// $check = SystemStoreStaff::where('phone',$userInfo['mobile'])->find()??[];
// if ($check){
// $userInfo['is_staff'] = 1;
// $userInfo['store_id'] = $check['store_id'];
// }
// }
Db::commit();
// Db::commit();
return $userInfo;
} catch (\Exception $e) {
Db::rollback();
// Db::rollback();
self::$error = $e->getMessage();
return false;
}

View File

@ -62,7 +62,8 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['product_id'] = $v['goods'];
$cart_select[$k]['old_cart_id'] = implode(',', $cartId);
$cart_select[$k]['cart_num'] = $v['cart_num'];
$cart_select[$k]['verify_code'] = $params['verify_code'];
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
$cart_select[$k]['cart_info'] = json_encode($cart_select[$k]);
//理论上每笔都是拆分了
// $cart_select[$k]['name'] = $find['store_name'];
// $cart_select[$k]['imgs'] = $find['image'];
@ -79,8 +80,8 @@ class OrderLogic extends BaseLogic
'total_num' => count($cart_select),//总数
'pay_type' => $params['pay_type'] ?? 0,
'cart_id' => implode(',', $cartId),
'store_id' => $params['store_id'],
'shipping_type' => $params['shipping_type']//配送方式 1=快递 2=门店自提
'store_id' => $params['store_id'] ?? 0,
'shipping_type' => $params['shipping_type'] ?? 1//配送方式 1=快递 2=门店自提
// 'delivery_msg'=>' 预计48小时发货 '
];
} catch (\Exception $e) {
@ -129,6 +130,7 @@ class OrderLogic extends BaseLogic
// if($params['pay_type']==PayEnum::CASH_PAY){
// $_order['money']=$_order['total'];
// }
Db::startTrans();
try {
$order = StoreOrder::create($_order);
@ -138,15 +140,6 @@ class OrderLogic extends BaseLogic
$goods_list[$k]['uid'] = request()->userId;
$goods_list[$k]['cart_id'] = implode(',', $cartId);
$goods_list[$k]['delivery_id'] = $params['store_id'];//商家id
$goods_list[$k]['cart_info'] = json_encode([
'goods' => $v['product_id'],
'cart_num' => $v['cart_num'],
'total' => $v['total'],
'price' => $v['price'],
'product_id' => $v['product_id'],
'old_cart_id' => $v['old_cart_id'],
'verify_code' => $v['verify_code']
], JSON_UNESCAPED_UNICODE);
}
(new StoreOrderCartInfo())->saveAll($goods_list);
$where = ['is_pay' => 0];

View File

@ -68,7 +68,7 @@ class AddressLogic extends BaseLogic
'detail' => $params['detail'],
'is_default' => $params['is_default'],
];
UserAddress::where('uid', $params['uid'])->where('address_id', $params['address_id'])->update($data);
UserAddress::where('uid', $params['uid'])->where('id', $params['address_id'])->update($data);
Db::commit();
return true;
} catch (\Exception $e) {
@ -101,6 +101,6 @@ class AddressLogic extends BaseLogic
*/
public static function detail($params): array
{
return UserAddress::field('address_id,real_name,phone,detail,is_default')->findOrEmpty($params['address_id'])->toArray();
return UserAddress::field('id address_id,real_name,phone,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray();
}
}

View File

@ -77,7 +77,7 @@ class WechatUserService
$this->user = $user;
if(!$user->isEmpty()){
$this->user->supplier=Supplier::where('uid',$user['id'])->with('userAuth')->field('id,mer_name')->find();
// $this->user->supplier=Supplier::where('uid',$user['id'])->with('userAuth')->field('id,mer_name')->find();
}
// $this->user->merchat=Merchant::where('uid',$user['id'])->find();
return $this;

View File

@ -34,9 +34,9 @@ class PaymentLogic extends BaseLogic
public static function pay($payWay, $from, $order, $terminal, $redirectUrl)
{
// 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
$paySn = $order['number'];
if ($order['actual'] == 0) {
PayNotifyLogic::handle($from, $order['number']);
$paySn = $order['order_id'];
if ($order['pay_price'] == 0) {
PayNotifyLogic::handle($from, $order['order_id']);
return ['pay_way' => PayEnum::BALANCE_PAY];
}
switch ($payWay) {
@ -46,11 +46,11 @@ class PaymentLogic extends BaseLogic
'out_trade_no' => $paySn,
'description' => '商品',
'amount' => [
'total' => intval($order['actual'] * 100),
'total' => intval($order['pay_price'] * 100),
'currency' => 'CNY',
],
"payer" => [
"openid" => $auth['openid'] ?? 0
"openid" => $auth['openid'] ?? 'onoIP7c1qgjfIr2ce7GJAAmVGcL0'
],
'attach' => $from
];

View File

@ -351,11 +351,11 @@ if (!function_exists('generateUniqueVerificationCode')) {
$msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
// 生成一个随机数作为核销码的后缀
$randomNumber = mt_rand(10000000, 99999999); // 假设核销码是8位数
$randomNumber = mt_rand(100, 999); // 假设核销码是8位数
// 将前缀、毫秒时间戳和随机数连接起来
$type = rand(1, 10); // 生成一个1-10之间的随机数作为前缀
return $type . $msectime . $randomNumber;
return $type .'-'. $msectime . $randomNumber;
}
}