Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
# Conflicts: # app/api/controller/order/OrderController.php # app/api/logic/order/OrderLogic.php
This commit is contained in:
commit
14bc0c1539
@ -20,7 +20,7 @@
|
|||||||
$cid = $this->request->post('cid', 0);
|
$cid = $this->request->post('cid', 0);
|
||||||
$result = UploadService::image($cid);
|
$result = UploadService::image($cid);
|
||||||
return $this->success('上传成功', $result);
|
return $this->success('上传成功', $result);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->fail($e->getMessage());
|
return $this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ class UserController extends BaseApiController
|
|||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
return $this->fail(UserLogic::getError());
|
return $this->fail(UserLogic::getError());
|
||||||
}
|
}
|
||||||
return $this->success('绑定成功', [], 1, 1);
|
$data = UserLogic::info($this->userId);
|
||||||
|
return $this->success('绑定成功', $data, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['paid','status','source'],
|
'=' => ['paid','status'],
|
||||||
'between_time' => 'create_time',
|
'between_time' => 'create_time',
|
||||||
'%like%' => ['number'],
|
'%like%' => ['order_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ class UserAddressList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
$user_id=$this->request->userId;
|
$user_id=$this->request->userId;
|
||||||
if(!$user_id) return [];
|
if(!$user_id) return [];
|
||||||
return UserAddress::where($this->searchWhere)->where('uid',$user_id)
|
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)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['address_id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ use app\common\service\{
|
|||||||
};
|
};
|
||||||
use app\common\model\user\{User, UserAuth};
|
use app\common\model\user\{User, UserAuth};
|
||||||
use app\common\service\wechat\WeChatMnpService;
|
use app\common\service\wechat\WeChatMnpService;
|
||||||
use think\facade\Db;
|
|
||||||
use Webman\Config;
|
use Webman\Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +221,7 @@ class LoginLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function mnpLogin(array $params)
|
public static function mnpLogin(array $params)
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
// Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//通过code获取微信 openid
|
//通过code获取微信 openid
|
||||||
$response = (new WeChatMnpService())->getMnpResByCode($params['code']);
|
$response = (new WeChatMnpService())->getMnpResByCode($params['code']);
|
||||||
@ -229,21 +229,11 @@ class LoginLogic extends BaseLogic
|
|||||||
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
|
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
|
||||||
// 更新登录信息
|
// 更新登录信息
|
||||||
self::updateLoginInfo($userInfo['id']);
|
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;
|
return $userInfo;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
// Db::rollback();
|
||||||
self::$error = $e->getMessage();
|
self::$error = $e->getMessage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,8 @@ class OrderLogic extends BaseLogic
|
|||||||
$cart_select[$k]['product_id'] = $v['goods'];
|
$cart_select[$k]['product_id'] = $v['goods'];
|
||||||
$cart_select[$k]['old_cart_id'] = implode(',', $cartId);
|
$cart_select[$k]['old_cart_id'] = implode(',', $cartId);
|
||||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
$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]['name'] = $find['store_name'];
|
||||||
// $cart_select[$k]['imgs'] = $find['image'];
|
// $cart_select[$k]['imgs'] = $find['image'];
|
||||||
@ -79,8 +80,8 @@ class OrderLogic extends BaseLogic
|
|||||||
'total_num' => count($cart_select),//总数
|
'total_num' => count($cart_select),//总数
|
||||||
'pay_type' => $params['pay_type'] ?? 0,
|
'pay_type' => $params['pay_type'] ?? 0,
|
||||||
'cart_id' => implode(',', $cartId),
|
'cart_id' => implode(',', $cartId),
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'] ?? 0,
|
||||||
'shipping_type' => $params['shipping_type']//配送方式 1=快递 ,2=门店自提
|
'shipping_type' => $params['shipping_type'] ?? 1//配送方式 1=快递 ,2=门店自提
|
||||||
// 'delivery_msg'=>' 预计48小时发货 '
|
// 'delivery_msg'=>' 预计48小时发货 '
|
||||||
];
|
];
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -129,6 +130,7 @@ class OrderLogic extends BaseLogic
|
|||||||
// if($params['pay_type']==PayEnum::CASH_PAY){
|
// if($params['pay_type']==PayEnum::CASH_PAY){
|
||||||
// $_order['money']=$_order['total'];
|
// $_order['money']=$_order['total'];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$order = StoreOrder::create($_order);
|
$order = StoreOrder::create($_order);
|
||||||
@ -138,15 +140,6 @@ class OrderLogic extends BaseLogic
|
|||||||
$goods_list[$k]['uid'] = request()->userId;
|
$goods_list[$k]['uid'] = request()->userId;
|
||||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||||
$goods_list[$k]['delivery_id'] = $params['store_id'];//商家id
|
$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);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
|
@ -68,7 +68,7 @@ class AddressLogic extends BaseLogic
|
|||||||
'detail' => $params['detail'],
|
'detail' => $params['detail'],
|
||||||
'is_default' => $params['is_default'],
|
'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();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -101,6 +101,6 @@ class AddressLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class WechatUserService
|
|||||||
|
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
if(!$user->isEmpty()){
|
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();
|
// $this->user->merchat=Merchant::where('uid',$user['id'])->find();
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -34,9 +34,9 @@ class PaymentLogic extends BaseLogic
|
|||||||
public static function pay($payWay, $from, $order, $terminal, $redirectUrl)
|
public static function pay($payWay, $from, $order, $terminal, $redirectUrl)
|
||||||
{
|
{
|
||||||
// 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
|
// 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
|
||||||
$paySn = $order['number'];
|
$paySn = $order['order_id'];
|
||||||
if ($order['actual'] == 0) {
|
if ($order['pay_price'] == 0) {
|
||||||
PayNotifyLogic::handle($from, $order['number']);
|
PayNotifyLogic::handle($from, $order['order_id']);
|
||||||
return ['pay_way' => PayEnum::BALANCE_PAY];
|
return ['pay_way' => PayEnum::BALANCE_PAY];
|
||||||
}
|
}
|
||||||
switch ($payWay) {
|
switch ($payWay) {
|
||||||
@ -46,11 +46,11 @@ class PaymentLogic extends BaseLogic
|
|||||||
'out_trade_no' => $paySn,
|
'out_trade_no' => $paySn,
|
||||||
'description' => '商品',
|
'description' => '商品',
|
||||||
'amount' => [
|
'amount' => [
|
||||||
'total' => intval($order['actual'] * 100),
|
'total' => intval($order['pay_price'] * 100),
|
||||||
'currency' => 'CNY',
|
'currency' => 'CNY',
|
||||||
],
|
],
|
||||||
"payer" => [
|
"payer" => [
|
||||||
"openid" => $auth['openid'] ?? 0
|
"openid" => $auth['openid'] ?? 'onoIP7c1qgjfIr2ce7GJAAmVGcL0'
|
||||||
],
|
],
|
||||||
'attach' => $from
|
'attach' => $from
|
||||||
];
|
];
|
||||||
|
@ -351,11 +351,11 @@ if (!function_exists('generateUniqueVerificationCode')) {
|
|||||||
$msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
|
$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之间的随机数作为前缀
|
$type = rand(1, 10); // 生成一个1-10之间的随机数作为前缀
|
||||||
return $type . $msectime . $randomNumber;
|
return $type .'-'. $msectime . $randomNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user