diff --git a/app/common/dao/store/order/StoreGroupOrderOtherDao.php b/app/common/dao/store/order/StoreGroupOrderOtherDao.php new file mode 100644 index 00000000..7697ea7a --- /dev/null +++ b/app/common/dao/store/order/StoreGroupOrderOtherDao.php @@ -0,0 +1,101 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\store\order; + + +use app\common\dao\BaseDao; +use app\common\model\store\order\StoreGroupOrderOther; +use app\common\model\store\order\StoreOrderOther; + +/** + * Class StoreGroupOrderOtherDao + * @package app\common\dao\store\order + * @author xaboy + * @day 2020/6/9 + */ +class StoreGroupOrderOtherDao extends BaseDao +{ + + /** + * @return string + * @author xaboy + * @day 2020/6/9 + */ + protected function getModel(): string + { + return StoreGroupOrderOther::class; + } + + /** + * @param null $uid + * @return int + * @author xaboy + * @day 2020/6/11 + */ + public function orderNumber($uid = null, $productType = 0) + { + $storeOrderWhere = StoreOrderOther::where('activity_type', $productType); + return StoreGroupOrderOther::hasWhere('orderList', $storeOrderWhere)->when($uid, function ($query, $uid) { + $query->where('StoreGroupOrder.uid', $uid); + })->where('StoreGroupOrder.is_del', 0)->whereRaw("(StoreGroupOrder.paid=0 and status!=12) or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8 and StoreOrder.status=2)")->count(); + } + + /** + * @param array $where + * @return \think\db\BaseQuery + * @author xaboy + * @day 2020/6/9 + */ + public function search(array $where) + { + return StoreGroupOrderOther::getDB()->alias('StoreGroupOrder')->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) { + if ($where['paid'] == 0) { + $query->whereRaw("StoreGroupOrder.paid=0 or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8)"); + } else { + $query->where('StoreGroupOrder.paid', $where['paid']); + } + })->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { + $query->where('StoreGroupOrder.uid', $where['uid']); + })->order('create_time DESC')->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) { + $query->where('StoreGroupOrder.is_del', $where['is_del']); + }, function ($query) { + $query->where('StoreGroupOrder.is_del', 0); + }); + } + + /** + * @param $time + * @param bool $is_remind + * @return array + * @author xaboy + * @day 2020/6/9 + */ + public function getTimeOutIds($time, $is_remind = false) + { + return StoreGroupOrderOther::getDB()->where('is_del', 0)->where('paid', 0) + ->when($is_remind, function ($query) { + $query->where('is_remind', 0); + })->where('create_time', '<=', $time)->column('group_order_id'); + } + + public function isRemind($id) + { + return StoreGroupOrderOther::getDB()->where('group_order_id', $id)->update(['is_remind' => 1]); + } + + public function totalNowMoney($uid) + { + return StoreGroupOrderOther::getDB()->where('pay_type', 0)->where('uid', $uid)->sum('pay_price') ?: 0; + } +} diff --git a/app/common/dao/store/order/StoreOrderOtherDao.php b/app/common/dao/store/order/StoreOrderOtherDao.php index c0dec4a6..10269a25 100644 --- a/app/common/dao/store/order/StoreOrderOtherDao.php +++ b/app/common/dao/store/order/StoreOrderOtherDao.php @@ -15,7 +15,7 @@ namespace app\common\dao\store\order; use app\common\dao\BaseDao; -use app\common\model\store\order\StoreOtherGroupOrder; +use app\common\model\store\order\StoreGroupOrderOther; use app\common\model\store\order\StoreOrderOther; use app\common\model\store\order\StoreOrderProductOther; use app\common\model\store\order\StoreOrderStatusOther; @@ -108,7 +108,7 @@ class StoreOrderOtherDao extends BaseDao $query->where('StoreOrderOther.paid', 1)->whereIn('StoreOrderOther.status', [10, 11]); break; case 2: - $query->where('StoreOrderOther.paid', 1)->where('StoreOrderOther.status', $where['status'])->where('pay_type', '<>', StoreGroupOrder::PAY_TYPE_CREDIT_BUY); + $query->where('StoreOrderOther.paid', 1)->where('StoreOrderOther.status', $where['status'])->where('pay_type', '<>', StoreGroupOrderOther::PAY_TYPE_CREDIT_BUY); break; case 20: $query->where('StoreOrderOther.paid', 1)->whereIn('StoreOrderOther.status', [2, 3]); @@ -206,7 +206,7 @@ class StoreOrderOtherDao extends BaseDao $query->where('order_sn', 'like', '%' . $where['order_search'] . '%')->whereOr('user_phone', $where['order_search']); }) ->when(isset($where['group_order_sn']) && $where['group_order_sn'] !== '', function ($query) use ($where) { - $query->join('StoreGroupOrder GO', 'StoreOrderOther.group_order_id = GStoreOrderOther.group_order_id')->where('group_order_sn', $where['group_order_sn']); + $query->join('StoreGroupOrderOther GO', 'StoreOrderOther.group_order_id = GO.group_order_id')->where('group_order_sn', $where['group_order_sn']); }) ->when(isset($where['keywords']) && $where['keywords'] !== '', function ($query) use ($where) { $query->where(function ($query) use ($where) { @@ -533,7 +533,7 @@ class StoreOrderOtherDao extends BaseDao { return StoreOrderStatusOther::getDB()->alias('A')->leftJoin('StoreOrderOther B', 'A.order_id = B.order_id') ->where('A.change_type', 'take') - ->where('A.change_time', '<', $end)->where('B.paid', 1)->where('B.status', 2)->where('B.pay_type', '<>', StoreGroupOrder::PAY_TYPE_CREDIT_BUY) + ->where('A.change_time', '<', $end)->where('B.paid', 1)->where('B.status', 2)->where('B.pay_type', '<>', StoreGroupOrderOther::PAY_TYPE_CREDIT_BUY) ->column('A.order_id'); } diff --git a/app/common/dao/system/merchant/FinancialRecordTransferDao.php b/app/common/dao/system/merchant/FinancialRecordTransferDao.php new file mode 100644 index 00000000..76c97f34 --- /dev/null +++ b/app/common/dao/system/merchant/FinancialRecordTransferDao.php @@ -0,0 +1,120 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\system\merchant; + + +use app\common\dao\BaseDao; +use app\common\model\system\merchant\FinancialRecordTransfer; + +class FinancialRecordTransferDao extends BaseDao +{ + + const Outlay = 0; //支出 + const Income = 1; //收入 + + const TypeMerchant = 0; //商户 + const TypeCommon = 1; //公共 + const TypePlatform = 2; //平台 + + protected function getModel(): string + { + return FinancialRecordTransfer::class; + } + + /** + * @return string + * @author xaboy + * @day 2020/6/9 + */ + public function getSn() + { + list($msec, $sec) = explode(' ', microtime()); + $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', ''); + $orderId = 'jy' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369)); + return $orderId; + } + + public function inc(array $data, $merId) + { + $data['mer_id'] = $merId; + $data['financial_pm'] = 1; + $data['financial_record_sn'] = $this->getSn(); + return $this->create($data); + } + + public function dec(array $data, $merId) + { + $data['mer_id'] = $merId; + $data['financial_pm'] = 0; + $data['financial_record_sn'] = $this->getSn(); + return $this->create($data); + } + + public function search(array $where) + { + $query = $this->getModel()::getDB() + ->when(isset($where['financial_type']) && $where['financial_type'] !== '', function ($query) use ($where) { + $query->whereIn('financial_type', $where['financial_type']); + }) + ->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) { + $query->where('mer_id', $where['mer_id']); + }) + ->when(isset($where['user_info']) && $where['user_info'] !== '', function ($query) use ($where) { + $query->where('user_info', $where['user_info']); + }) + ->when(isset($where['user_id']) && $where['user_id'] !== '', function ($query) use ($where) { + $query->where('user_id', $where['user_id']); + }) + ->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) { + $query->whereLike('order_sn|user_info|financial_record_sn', "%{$where['keyword']}%"); + }) + ->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { + getModelTime($query, $where['date'], 'create_time'); + }) + ->when(isset($where['is_mer']) && $where['is_mer'] !== '', function ($query) use ($where) { + if($where['is_mer']){ + $query->where('mer_id',$where['is_mer'])->where('type','in',[0,1]); + }else{ + $query->where('type','in',[1,2]); + } + }); + return $query; + } + + /** + * TODO 根据条件和时间查询出相对类型的数量个金额 + * @param int $type + * @param array $where + * @param string $date + * @param array $financialType + * @return array + * @author Qinii + * @day 4/14/22 + */ + public function getDataByType(int $type, array $where, string $date, array $financialType) + { + if (empty($financialType)) return [0,0]; + $query = $this->search($where)->where('financial_type','in',$financialType); + + if($type == 1) { + $query->whereDay('create_time',$date); + } else { + $query->whereMonth('create_time',$date); + } + $count = $query->group('order_id')->where('number', '<>', 0)->count(); + $number = $query->where('number', '<>', 0)->sum('number'); + + return [$count,$number]; + } +} diff --git a/app/common/model/store/order/StoreOrderOther.php b/app/common/model/store/order/StoreOrderOther.php index 14a4d96d..084c1cfe 100644 --- a/app/common/model/store/order/StoreOrderOther.php +++ b/app/common/model/store/order/StoreOrderOther.php @@ -18,7 +18,6 @@ use app\common\model\BaseModel; use app\common\model\community\Community; use app\common\model\store\product\ProductGroupUser; use app\common\model\store\service\StoreService; -use app\common\model\store\shipping\Express; use app\common\model\system\merchant\Merchant; use app\common\model\user\User; use app\common\repositories\store\MerchantTakeRepository; @@ -154,7 +153,7 @@ class StoreOrderOther extends BaseModel public function getOrderExtendAttr($val) { - return $val ? json_decode($val, true) : null; + return $val ? json_decode($val, true) : []; } public function getRefundExtensionOneAttr() diff --git a/app/common/model/system/merchant/FinancialRecordTransfer.php b/app/common/model/system/merchant/FinancialRecordTransfer.php new file mode 100644 index 00000000..6a8269ae --- /dev/null +++ b/app/common/model/system/merchant/FinancialRecordTransfer.php @@ -0,0 +1,47 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\system\merchant; + + +use app\common\model\BaseModel; +use app\common\model\store\order\StoreOrderOther; +use app\common\model\user\User; + +class FinancialRecordTransfer extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'financial_record_id'; + } + + public static function tableName(): string + { + return 'financial_record_transfer'; + } + + public function user() + { + return $this->hasOne(User::class,'uid','user_id'); + } + + public function merchant() + { + return $this->hasOne(Merchant::class,'mer_id','mer_id'); + } + public function orderInfo() + { + return $this->hasOne(StoreOrderOther::class,'order_sn','order_sn'); + } +} diff --git a/app/common/repositories/store/order/StoreGroupOrderOtherRepository.php b/app/common/repositories/store/order/StoreGroupOrderOtherRepository.php new file mode 100644 index 00000000..a1fc59e7 --- /dev/null +++ b/app/common/repositories/store/order/StoreGroupOrderOtherRepository.php @@ -0,0 +1,151 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\store\order; + + +use app\common\dao\store\order\StoreGroupOrderDao; +use app\common\model\store\order\StoreGroupOrderOther; +use app\common\model\store\order\StoreOrderOther; +use app\common\repositories\BaseRepository; +use think\db\exception\DataNotFoundException; +use think\model\Relation; + +/** + * Class StoreGroupOrderOtherRepository + * @package app\common\repositories\store\order + * @author xaboy + * @day 2020/6/8 + * @mixin StoreGroupOrderDao + */ +class StoreGroupOrderOtherRepository extends BaseRepository +{ + + public $getAll = false; + + /** + * StoreGroupOrderRepository constructor. + * @param StoreGroupOrderDao $dao + */ + public function __construct(StoreGroupOrderDao $dao) + { + $this->dao = $dao; + } + + /** + * @param array $where + * @param $page + * @param $limit + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function getList(array $where, $page, $limit) + { + $query = StoreGroupOrderOther::getDB()->alias('StoreGroupOrder'); + if (isset($where['product_type'])) { + $storeOrderWhere = StoreOrderOther::where('activity_type', $where['product_type']); + $query->hasWhere('orderList', $storeOrderWhere); + } + $query->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) { + if ($where['paid'] == 0) { + $query->whereRaw("(StoreGroupOrder.paid=0 and status!=12) or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8 and StoreOrder.status=2)"); + } else { + $query->where('StoreGroupOrder.paid', $where['paid']); + } + })->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { + $query->where('StoreGroupOrder.uid', $where['uid']); + })->order('create_time DESC')->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) { + $query->where('StoreGroupOrder.is_del', $where['is_del']); + }, function ($query) { + $query->where('StoreGroupOrder.is_del', 0); + }); + $count = $query->count(); + $groupList = $query->with(['orderList' => function (Relation $query) { + $query->field('order_id,group_order_id,activity_type,pay_price,status,mer_id')->with(['merchant' => function ($query) { + $query->field('mer_id,mer_name,settle_cycle,interest_rate'); + }, 'orderProduct','presellOrder']); + }, 'interest'])->page($page, $limit)->order('create_time DESC')->select(); + $list = []; + foreach ($groupList as $k => $item) { + $current = $item->toArray(); + if (!empty($item->interest)) { + $interest = $item->interest->calculateInterest(); + $current['interest']['total_amount'] = bcadd($item->interest->total_price, $interest, 2); + } else { + $current['interest']['total_amount'] = $item['total_price']; + } + $list[] = $current; + } + return compact('count', 'list'); + } + + /** + * @param $uid + * @param $id + * @return array|\think\Model|null + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function detail($id, $flag = true) + { + // 'paid' => 0 + $order = StoreGroupOrderOther::where('group_order_id', $id) + ->where('is_del', 0) + ->with(['orderList' => function (Relation $query) use ($flag) { + $query->when($flag, function ($query) { + $query->field('order_id,group_order_id,mer_id,order_sn,activity_type,pay_price,order_extend,order_type,is_virtual'); + })->with(['merchant' => function ($query) use ($flag) { + $flag && $query->field('mer_id,mer_name,settle_cycle,interest_rate'); + }, 'orderProduct', 'presellOrder']); + }, 'interest']) + ->order('create_time DESC')->append(['cancel_time', 'cancel_unix'])->find(); + if ($order['paid'] == 1) { + throw new DataNotFoundException('订单不存在或已取消'); + } + if (empty($order)) { + throw new DataNotFoundException('订单不存在或已取消'); + } + if (!empty($order->interest)) { + $interest = $order->interest->calculateInterest(); + $order->interest->interest = $interest; + $order->interest->total_amount = bcadd($order->interest->total_price, $interest, 2); + } + return $order; + } + + public function status($uid, $id) + { + return $this->search(['uid' => $uid])->where('group_order_id', $id)->append(['give_coupon'])->find(); + } + + /** + * @param $id + * @return array|\think\Model|null + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function getCancelDetail($id) + { + return $this->search(['paid' => 0, 'is_del' => 1])->where('group_order_id', $id)->with(['orderList.orderProduct'])->find(); + } +} diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 327baea7..52b2ba5b 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -1084,7 +1084,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } } - Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'id' => $group->group_order_id]); + // Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'id' => $group->group_order_id, + // 'activity_type'=>$group->activity_type,'order_id'=>$group->order_id]); return $group; } } diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 96682a73..1b0e1e3a 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -462,6 +462,23 @@ class StoreOrderRepository extends BaseRepository if (count($groupOrder['give_coupon_ids']) > 0) $groupOrder['give_coupon_ids'] = app()->make(StoreCouponRepository::class)->getGiveCoupon($groupOrder['give_coupon_ids'])->column('coupon_id'); $groupOrder->save(); + $group_id=0; + if($order->activity_type==98){ + $group_id=Db::name('system_group')->where('group_key','city_operations')->value('group_id'); + }else{ + $group_id=Db::name('system_group')->where('group_key','town_operation')->value('group_id'); + } + if($group_id){ + $group_value=Db::name('system_group_data')->where('group_id',$group_id)->column('value'); + if($group_value){ + foreach($group_value as $k=>$v){ + $phone=json_decode($v,true); + Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $phone['phone'],'orderId'=>$order->order_id,'id'=>0]);//短信通知 + } + } + + } + }); if (count($groupOrder['give_coupon_ids']) > 0) { @@ -470,7 +487,6 @@ class StoreOrderRepository extends BaseRepository } catch (Exception $e) { } } - Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_PAY_SUCCESS', 'id' => $groupOrder->group_order_id]); Queue::push(SendSmsJob::class, ['tempId' => 'ADMIN_PAY_SUCCESS_CODE', 'id' => $groupOrder->group_order_id]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]); diff --git a/app/common/repositories/store/order/StoreOtherOrderCreateRepository.php b/app/common/repositories/store/order/StoreOtherOrderCreateRepository.php index 17729ad2..ca8eda07 100644 --- a/app/common/repositories/store/order/StoreOtherOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOtherOrderCreateRepository.php @@ -2,33 +2,19 @@ namespace app\common\repositories\store\order; -use app\common\dao\store\order\StoreCartDao; -use app\common\model\store\order\StoreGroupOrder; -use app\common\model\store\order\StoreOrder; -use app\common\model\system\merchant\Merchant; -use app\common\repositories\community\CommunityRepository; -use app\common\repositories\store\coupon\StoreCouponRepository; + use app\common\repositories\store\coupon\StoreCouponUserRepository; -use app\common\repositories\store\product\ProductAssistSkuRepository; use app\common\repositories\store\product\ProductAttrValueRepository; -use app\common\repositories\store\product\ProductGroupSkuRepository; -use app\common\repositories\store\product\ProductPresellSkuRepository; use app\common\repositories\store\product\ProductRepository; -use app\common\repositories\store\product\StoreDiscountRepository; -use app\common\repositories\store\StoreCategoryRepository; use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\user\MemberinterestsRepository; use app\common\repositories\user\UserAddressRepository; -use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserMerchantRepository; use app\common\repositories\user\UserRepository; use app\validate\api\OrderVirtualFieldValidate; use app\validate\api\UserAddressValidate; -use crmeb\jobs\SendSmsJob; -use crmeb\services\SwooleTaskService; use think\exception\ValidateException; use think\facade\Db; -use think\facade\Queue; class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository { @@ -493,14 +479,15 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository } else { $extend = []; } - $orderType = $orderInfo['order_type']; - if ($orderType == 0 && $pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { - throw new ValidateException('该商品不支持先货后款'); + if(isset($orderInfo['address']['street_code'])){ + $getUrl = env('TASK.WORKER_HOST_URL') . '/api/index/getCompanyBankInfo?street_code='.$orderInfo['address']['street_code']; + $client = new \GuzzleHttp\Client(); + $response = $client->request('GET', $getUrl); + $courierData = json_decode($response->getBody(), true); + if (!empty($courierData['code']) || $courierData['code'] == 1) { + $extend['bank_info']=$courierData['data']; + } } - if (!in_array($orderType, [0, 98, 99]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { - throw new ValidateException('活动商品请单独购买'); - } - $merchantCartList = $orderInfo['order']; $cartSpread = 0; $hasTake = false; @@ -596,8 +583,6 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository 'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2), 'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'], 'pay_type' => $pay_type, - 'paid'=>1, - 'pay_time'=>date('Y-m-d H:i:s',time()), ]; $allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']); $orderList[] = $_order; @@ -737,21 +722,6 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository Db::name('store_order_product_other')->insertAll($orderProduct); return $groupOrder; }); - foreach ($merchantCartList as $merchantCart) { - foreach ($merchantCart['list'] as $cart) { - if (($cart['productAttr']['stock'] - $cart['cart_num']) < (int)merchantConfig($merchantCart['mer_id'], 'mer_store_stock')) { - SwooleTaskService::merchant('notice', [ - 'type' => 'min_stock', - 'data' => [ - 'title' => '库存不足', - 'message' => $cart['product']['store_name'] . '(' . $cart['productAttr']['sku'] . ')库存不足', - 'id' => $cart['product']['product_id'] - ] - ], $merchantCart['mer_id']); - } - } - } - // Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'id' => $group->group_order_id]); return $group; } } diff --git a/app/common/repositories/store/order/StoreOtherOrderRepository.php b/app/common/repositories/store/order/StoreOtherOrderRepository.php index 4f935036..a7d4ce4b 100644 --- a/app/common/repositories/store/order/StoreOtherOrderRepository.php +++ b/app/common/repositories/store/order/StoreOtherOrderRepository.php @@ -11,51 +11,29 @@ // +---------------------------------------------------------------------- namespace app\common\repositories\store\order; -use app\common\dao\store\order\StoreCartDao; use app\common\dao\store\order\StoreOrderOtherDao; use app\common\model\store\order\StoreGroupOrderOther; -use app\common\model\store\order\StoreOtherOrder; use app\common\model\store\order\StoreOrderInterestOther; use app\common\model\store\order\StoreOrderOther; -use app\common\model\store\order\StoreOtherOrderInterest; use app\common\model\store\order\StoreRefundOrder; -use app\common\model\store\product\PurchaseRecord; use app\common\model\user\User; -use app\common\model\system\merchant\Merchant; use app\common\repositories\BaseRepository; -use app\common\repositories\delivery\DeliveryOrderRepository; -use app\common\repositories\store\coupon\StoreCouponRepository; -use app\common\repositories\store\coupon\StoreCouponUserRepository; -use app\common\repositories\store\product\ProductAssistSetRepository; -use app\common\repositories\store\product\ProductCopyRepository; -use app\common\repositories\store\product\ProductGroupBuyingRepository; -use app\common\repositories\store\product\ProductPresellSkuRepository; use app\common\repositories\store\product\ProductRepository; -use app\common\repositories\store\product\StoreDiscountRepository; use app\common\repositories\store\shipping\ExpressRepository; use app\common\repositories\store\StorePrinterRepository; -use app\common\repositories\store\StoreSeckillActiveRepository; use app\common\repositories\system\attachment\AttachmentRepository; use app\common\repositories\system\merchant\FinancialRecordRepository; use app\common\repositories\system\merchant\MerchantRepository; -use app\common\repositories\system\serve\ServeDumpRepository; use app\common\repositories\user\UserBillRepository; -use app\common\repositories\user\UserBrokerageRepository; use app\common\repositories\user\UserMerchantRepository; use app\common\repositories\user\UserRepository; -use crmeb\jobs\PayGiveCouponJob; -use crmeb\jobs\ProductImportJob; use crmeb\jobs\SendSmsJob; -use crmeb\jobs\SendGoodsCodeJob; -use crmeb\jobs\UserBrokerageLevelJob; use crmeb\services\CombinePayService; -use crmeb\services\CrmebServeServices; use crmeb\services\ExpressService; use crmeb\services\PayService; use crmeb\services\payTool\PayTool; use crmeb\services\printer\Printer; use crmeb\services\QrcodeService; -use crmeb\services\SpreadsheetExcelService; use crmeb\services\SwooleTaskService; use Exception; use FormBuilder\Factory\Elm; @@ -69,7 +47,6 @@ use think\facade\Log; use think\facade\Queue; use think\facade\Route; use think\Model; -use app\controller\admin\ProductLibrary; /**其他订单 @@ -173,7 +150,8 @@ class StoreOtherOrderRepository extends BaseRepository { $groupOrder->append(['user']); //修改订单状态 - Db::transaction(function () use ($subOrders, $is_combine, $groupOrder) { + Db::startTrans(); + try { $time = date('Y-m-d H:i:s'); $groupOrder->paid = 1; $groupOrder->pay_time = $time; @@ -191,9 +169,18 @@ class StoreOtherOrderRepository extends BaseRepository $i = 1; $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder); //订单记录 - $storeOrderStatusRepository = app()->make(StoreOtherOrderRepository::class); + $storeOrderStatusRepository = app()->make(StoreOrderStatusOtherRepository::class); $svipDiscount = 0; foreach ($groupOrder->orderList as $_k => $order) { + if($groupOrder->order_extend){ + if($order->order_extend){ + $order_extend=$order->order_extend; + }else{ + $order_extend=[]; + } + $order_extend['corporate_voucher']=$groupOrder->order_extend; + $order->order_extend=json_encode($order_extend,true); + } $order->paid = 1; $order->pay_time = $time; $svipDiscount = bcadd($order->svip_discount, $svipDiscount, 2); @@ -306,22 +293,11 @@ class StoreOtherOrderRepository extends BaseRepository 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; - $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2); + // $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2); } - if (!$is_combine) { - app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice); - } - } - if ($is_combine) { - $profitsharing[] = [ - 'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(), - 'order_id' => $order->order_id, - 'transaction_id' => $order->transaction_id ?? '', - 'mer_id' => $order->mer_id, - 'profitsharing_price' => $order->pay_price, - 'profitsharing_mer_price' => $_payPrice, - 'type' => $storeOrderProfitsharingRepository::PROFITSHARING_TYPE_ORDER, - ]; + // if (!$is_combine) { + // app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice); + // } } $userMerchantRepository->updatePayTime($uid, $order->mer_id, $order->pay_price); SwooleTaskService::merchant('notice', [ @@ -332,27 +308,37 @@ class StoreOtherOrderRepository extends BaseRepository 'id' => $order->order_id ] ], $order->mer_id); + + $group_id=0; + if($order->activity_type==98){ + $group_id=Db::name('system_group')->where('group_key','city_operations')->value('group_id'); + }else{ + $group_id=Db::name('system_group')->where('group_key','town_operation')->value('group_id'); + } + if($group_id){ + $group_value=Db::name('system_group_data')->where('group_id',$group_id)->column('value'); + if($group_value){ + foreach($group_value as $k=>$v){ + $phone=json_decode($v,true); + Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $phone['phone'],'orderId'=>$order->order_id,'id'=>0]);//短信通知 + } + } + + } } - app()->make(UserRepository::class)->update($groupOrder->uid, [ - 'pay_count' => Db::raw('pay_count+' . count($groupOrder->orderList)), - 'pay_price' => Db::raw('pay_price+' . $groupOrder->pay_price), - 'svip_save_money' => Db::raw('svip_save_money+' . $svipDiscount), - ]); $this->giveIntegral($groupOrder); - if (count($profitsharing)) { - $storeOrderProfitsharingRepository->insertAll($profitsharing); - } $financialRecordRepository->insertAll($finance); $storeOrderStatusRepository->batchCreateLog($orderStatus); - $groupOrder->save(); - }); - - Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_PAY_SUCCESS', 'id' => $groupOrder->group_order_id]); - Queue::push(SendSmsJob::class, ['tempId' => 'ADMIN_PAY_SUCCESS_CODE', 'id' => $groupOrder->group_order_id]); - Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]); - Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]); - app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id); + $groupOrder->save(); + Db::commit(); + return true; + } catch (\Exception $e) { + Log::error('财务点击支付失败'.$e->getMessage()); + // 回滚事务 + Db::rollback(); + return false; + } } @@ -703,7 +689,7 @@ class StoreOtherOrderRepository extends BaseRepository // $param['StoreOrderOther.paid'] = 0; break; // 未支付 case 2: - $param['StoreOrderOther.paid'] = 1; + $param['StoreOrderOther.paid'] = [1,2]; $param['StoreOrderOther.status'] = 0; break; // 待发货 case 3: @@ -1271,7 +1257,7 @@ class StoreOtherOrderRepository extends BaseRepository ->with([ 'orderProduct', 'merchant' => function ($query) { - return $query->field('mer_id,mer_name,is_trader'); + return $query->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate'); }, 'verifyService' => function ($query) { return $query->field('service_id,nickname'); @@ -1292,7 +1278,18 @@ class StoreOtherOrderRepository extends BaseRepository }, ]); $count = $query->count(); - $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']); + $list = $query->page($page, $limit)->select()->each(function ($item) { + $auto_margin= Db::name('financial_record_transfer') + ->where('order_id',$item['order_id'])->where('financial_type','auto_margin')->where('financial_pm',0)->value('number'); + $order_charge= Db::name('financial_record_transfer') + ->where('order_id',$item['order_id'])->where('financial_type','order_charge')->where('financial_pm',0)->value('number'); + $item['financial_record']=[ + 'auto_margin'=>$auto_margin, + 'auto_margin_lv'=>$item->merchant->auto_margin_rate, + 'order_charge'=>$order_charge, + 'order_charge_lv'=>$item->merchant->commission_rate?round($item->merchant->commission_rate,2):0, + ]; + }); return compact('count', 'list'); } diff --git a/app/common/repositories/system/merchant/FinancialRecordTransferRepository.php b/app/common/repositories/system/merchant/FinancialRecordTransferRepository.php new file mode 100644 index 00000000..3e815a90 --- /dev/null +++ b/app/common/repositories/system/merchant/FinancialRecordTransferRepository.php @@ -0,0 +1,548 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\repositories\system\merchant; + + +use app\common\dao\system\merchant\FinancialRecordTransferDao; +use app\common\repositories\BaseRepository; +use app\common\repositories\user\UserBillRepository; +use think\facade\Cache; +use think\facade\Db; + +/** + * Class FinancialRecordTransferRepository + * @package app\common\repositories\system\merchant + * @author xaboy + * @day 2020/8/5 + * @mixin FinancialRecordDao + */ +class FinancialRecordTransferRepository extends BaseRepository +{ + public function __construct(FinancialRecordTransferDao $dao) + { + $this->dao = $dao; + } + + /** + * TODO 列表 + * @param array $where + * @param int $page + * @param int $limit + * @return array + * @author Qinii + * @day 5/7/21 + */ + public function getList(array $where, int $page, int $limit) + { + $query = $this->dao->search($where)->order('create_time DESC'); + $count = $query->count(); + $list = $query->page($page, $limit)->select(); + return compact('count', 'list'); + } + + /** + * TODO 流水头部计算 + * @param int|null $merId + * @param array $where + * @return array + * @author Qinii + * @day 5/7/21 + */ + public function getFiniancialTitle(?int $merId, array $where) + { + /** + * 平台支出 + * 商户的收入 order_true + 佣金 brokerage_one,brokerage_two + 手续费 refund_charge + 商户预售收入 presell_true + * + * 商户支出 + * 退回收入 refund_order + (佣金 brokerage_one,brokerage_two - 退回佣金 refund_brokerage_two,refund_brokerage_one ) + (手续费 order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge ) + */ + $where['is_mer'] = $merId; + if ($merId) { + //商户收入 + $income = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell'])->sum('number'); + //商户支出 + $expend_ = $this->dao->search($where)->where('financial_type', 'in', ['refund_order', 'brokerage_one', 'brokerage_two', 'order_charge', 'presell_charge'])->sum('number'); + $_expend = $this->dao->search($where)->where('financial_type', 'in', ['refund_charge', 'refund_brokerage_two', 'refund_brokerage_one'])->sum('number'); + $expend = bcsub($expend_, $_expend, 2); + $msg = '商户'; + } else { + //平台收入 + $income = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number'); + //平台支出 + $expend = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two', 'order_true', 'refund_charge', 'presell_true', 'order_platform_coupon', 'order_svip_coupon'])->sum('number'); + $msg = '平台'; + } + $data = [ + [ + 'className' => 'el-icon-s-goods', + 'count' => $income, + 'field' => '元', + 'name' => $msg . '收入' + ], + [ + 'className' => 'el-icon-s-order', + 'count' => $expend, + 'field' => '元', + 'name' => $msg . '支出' + ], + ]; + return $data; + } + + /** + * TODO 平台头部统计 + * @param $where + * @return array + * @author Qinii + * @day 3/23/21 + */ + public function getAdminTitle($where) + { + //订单收入总金额 + $count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number'); + //佣金支出金额 + $brokerage_ = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number'); + $_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number'); + $brokerage = bcsub($brokerage_, $_brokerage, 2); + + //入口店铺佣金 + $entry_merchant=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant')->sum('number'); + $entry_merchant_refund=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant_refund')->sum('number'); + + //平台手续费 + $charge_ = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number'); + $_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number'); + $charge = bcsub($charge_, $_charge, 2); + + //产生交易的商户数 + $mer_number = $this->dao->search($where)->group('mer_id')->count(); + + $stat = [ + [ + 'className' => 'el-icon-s-goods', + 'count' => $count, + 'field' => '元', + 'name' => '订单收入总金额' + ], + + [ + 'className' => 'el-icon-s-cooperation', + 'count' => $brokerage, + 'field' => '元', + 'name' => '佣金支出金额' + ], + [ + 'className' => 'el-icon-s-cooperation', + 'count' => $charge, + 'field' => '元', + 'name' => '平台手续费' + ], + [ + 'className' => 'el-icon-s-goods', + 'count' => $mer_number, + 'field' => '个', + 'name' => '产生交易的商户数' + ],[ + 'className' => 'el-icon-s-order', + 'count' => bcsub($entry_merchant,$entry_merchant_refund,2), + 'field' => '元', + 'name' => '入口商户佣金' + ], + ]; + return compact('stat'); + } + + /** + * TODO 商户头部统计 + * @param $where + * @return array + * @author Qinii + * @day 5/6/21 + */ + public function getMerchantTitle($where) + { + //商户收入 + $count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell'])->sum('number'); + //押金 + $auto_margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number'); + $auto_margin_refund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number'); + //平台手续费 + $refund_true = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number'); + $order_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number'); + $charge = bcsub($refund_true, $order_charge, 2); + $stat = [ + [ + 'className' => 'el-icon-s-goods', + 'count' => $count, + 'field' => '元', + 'name' => '商户收入' + ], + [ + 'className' => 'el-icon-s-cooperation', + 'count' => $charge, + 'field' => '元', + 'name' => '平台手续费' + ], [ + 'className' => 'el-icon-s-cooperation', + 'count' => bcsub($auto_margin,$auto_margin_refund,2), + 'field' => '元', + 'name' => '商户押金金额' + ], + ]; + return compact('stat'); + } + + /** + * TODO 月账单 + * @param array $where + * @param int $page + * @param int $limit + * @return array + * @author Qinii + * @day 3/23/21 + */ + public function getAdminList(array $where, int $page, int $limit, $merchant = []) + { + //日 + if ($where['type'] == 1) { + $field = Db::raw('from_unixtime(unix_timestamp(create_time),\'%Y-%m-%d\') as time'); + } else { + //月 + if (!empty($where['date'])) { + list($startTime, $endTime) = explode('-', $where['date']); + $firstday = date('Y/m/01', strtotime($startTime)); + $lastday_ = date('Y/m/01', strtotime($endTime)); + $lastday = date('Y/m/d', strtotime("$lastday_ +1 month -1 day")); + $where['date'] = $firstday . '-' . $lastday; + } + $field = Db::raw('from_unixtime(unix_timestamp(create_time),\'%Y-%m\') as time'); + } + $make = app()->make(UserBillRepository::class); + + $query = $this->dao->search($where)->field($field)->group("time")->order('create_time DESC'); + $count = $query->count(); + $list = $query->page($page, $limit)->select()->each(function ($item) use ($where, $merchant) { + $key = $where['is_mer'] ? $where['is_mer'] . '_financial_record_list_' . $item['time'] : 'sys_financial_record_list_' . $item['time']; + if (($where['type'] == 1 && ($item['time'] == date('Y-m-d', time()))) || ($where['type'] == 2 && ($item['time'] == date('Y-m', time())))) { + $income = ($this->countIncome($where['type'], $where, $item['time'],$merchant))['number']; + $expend = ($this->countExpend($where['type'], $where, $item['time'],$merchant))['number']; + $ret = [ + 'income' => $income, + 'expend' => $expend, + 'charge' => bcsub($income, $expend, 2), + ]; + } else { + if (!$ret = Cache::get($key)) { + $income = ($this->countIncome($where['type'], $where, $item['time'],$merchant))['number']; + $expend = ($this->countExpend($where['type'], $where, $item['time'],$merchant))['number']; + $ret = [ + 'income' => $income, + 'expend' => $expend, + 'charge' => bcsub($income, $expend, 2), + ]; + Cache::tag('system')->set($key, $ret, 24 * 3600); + } + } + $item['income'] = $ret['income']; + $item['expend'] = $ret['expend']; + $item['charge'] = $ret['charge']; + }); + + return compact('count', 'list'); + } + + /** + * TODO 平台详情 + * @param int $type + * @param array $where + * @return mixed + * @author Qinii + * @day 3/23/21 + */ + public function adminDetail(int $type, array $where) + { + $date_ = strtotime($where['date']); + unset($where['date']); + $date = ($type == 1) ? date('Y-m-d', $date_) : date('Y-m', $date_); + $income = $this->countIncome($type, $where, $date); + $bill = $this->countBill($type, $date); + $expend = $this->countExpend($type, $where, $date); + $charge = bcsub($income['number'], $expend['number'], 2); + $data['date'] = $date; + $data['income'] = [ + 'title' => '订单收入总金额', + 'number' => $income['number'], + 'count' => $income['count'] . '笔', + 'data' => [ + ['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'], + ] + ]; + $data['bill'] = [ + 'title' => '充值金额', + 'number' => $bill['number'], + 'count' => $bill['count'] . '笔', + 'data' => [] + ]; + $data['expend'] = [ + 'title' => '支出总金额', + 'number' => $expend['number'], + 'count' => $expend['count'] . '笔', + 'data' => [ + ['应付商户金额', $expend['number_order'] . '元', $expend['count_order'] . '笔'], + ['佣金', $expend['number_brokerage'] . '元', $expend['count_brokerage'] . '笔'], + ['返还手续费', $expend['number_charge'] . '元', $expend['count_charge'] . '笔'], + ] + ]; + $data['charge'] = [ + 'title' => '平台手续费收入总金额', + 'number' => $charge, + 'count' => '', + 'data' => [] + ]; + return $data; + } + + /** + * TODO 商户详情 + * @param int $type + * @param array $where + * @return mixed + * @author Qinii + * @day 5/6/21 + */ + public function merDetail(int $type, array $where,$merchant=[]) + { + $date_ = strtotime($where['date']); + unset($where['date']); + $date = ($type == 1) ? date('Y-m-d', $date_) : date('Y-m', $date_); + $income = $this->countIncome($type, $where, $date,$merchant); + $expend = $this->countExpend($type, $where, $date,$merchant); + $data['e'] = $expend; + $charge = bcsub($income['number'], $expend['number'], 2); + + $data['date'] = $date; + $data['income'] = [ + 'title' => '订单收入总金额', + 'number' => $income['number'], + 'count' => $income['count'] . '笔', + 'data' => [ + ['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'], + ] + ]; + $data['expend'] = [ + 'title' => '支出总金额', + 'number' => $expend['number'], + 'count' => $expend['count'] . '笔', + 'data' => [ + [ + '平台手续费', + bcsub($expend['number_order_charge'], $expend['number_charge'], 2). '元', + bcsub($expend['count_order_charge'], $expend['count_charge']). '笔', + ], + [ + '店铺押金', + $expend['number_auto_margin'] . '元', + $expend['count_auto_margin'] . '笔' + + ], + [ + '佣金', + bcsub($expend['number_brokerage'], $expend['number_refund_brokerage'], 2) . '元', + $expend['count_brokerage'] + $expend['count_refund_brokerage'] . '笔' + ], + [ + '商户退款', + $expend['number_refund'] . '元', + $expend['count_refund'] . '笔' + ], + ] + ]; + $data['charge'] = [ + 'title' => '应入账总金额', + 'number' => $charge, + 'count' => '', + 'data' => [] + ]; + + return $data; + } + + /** + * TODO 总收入 + * @param $type + * @param $date + * @return array + * @author Qinii + * @day 3/23/21 + */ + public function countIncome($type, $where, $date, $merchant = []) + { + $financialType = ['order', 'order_presell', 'presell', 'mer_presell']; + if ($merchant){ + switch ($merchant['type_id']) { + case 16: + $financialType1 = ['commission_to_town']; + break; + case 15: + $financialType1 = ['commission_to_village']; + break; + case 14: + $financialType1 = ['commission_to_service_team']; + break; + case 11: + $financialType1 = ['commission_to_cloud_warehouse']; + break; + case 10: + $financialType1 = ['commission_to_entry_merchant']; + break; + default: + $financialType1 = []; + } + + $financialType = array_merge($financialType, $financialType1); + } + [$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType); + if (!empty($financialType1)){ + $financialType1[0]=$financialType1[0].'_refund'; + [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType1); + $data['count_order']-=$data['count_refund']; + $data['number_order']-=$data['number_refund']; + } + + if ($where['is_mer']) { + $financialType = ['order_platform_coupon']; + } else { + $financialType = ['refund_platform_coupon']; + } + if ($where['is_mer']) { + $financialType = ['order_svip_coupon']; + } else { + $financialType = ['refund_svip_coupon']; + } + [$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + $data['count'] = $data['count_order']; + $data['number'] =$data['number_order']; + return $data; + } + + + /** + * TODO 平台总支出 + * @param $type + * @param $date + * @return array + * @author Qinii + * @day 3/23/21 + */ + public function countExpend($type, $where, $date,$merchant=[]) + { + /** + * 平台支出 + * 商户的收入 order_true + 佣金 brokerage_one,brokerage_two + 手续费 refund_charge + 商户预售收入 presell_true + * + * 商户支出 + * 退回收入 refund_order + (佣金 brokerage_one,brokerage_two - 退回佣金 refund_brokerage_two,refund_brokerage_one ) + (手续费 order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge ) + */ + // 退回佣金 + $financialType = ['brokerage_one', 'brokerage_two']; + [$data['count_brokerage'], $data['number_brokerage']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + // 退回手续费 + $financialType = ['refund_charge']; + [$data['count_charge'], $data['number_charge']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + if (!$merchant){ + //分成的 + $commission=['commission_to_town','commission_to_village','commission_to_service_team','commission_to_cloud_warehouse','commission_to_entry_merchant']; + } + if ($where['is_mer']) { //商户的 + //退回收入 + $financialType = ['refund_order']; + [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + //平台手续费 + $financialType = ['order_charge', 'presell_charge']; + [$data['count_order_charge'], $data['number_order_charge']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + //商户押金 + $financialType = ['auto_margin']; + [$data['count_auto_margin'], $data['number_auto_margin']] = $this->dao->getDataByType($type, $where, $date, $financialType); + //商户押金退回 + $financialType = ['auto_margin_refund']; + [$data['count_auto_margin_refund'], $data['number_auto_margin_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType); + $number3 = bcsub($data['number_auto_margin'], $data['number_auto_margin_refund'], 2); + $data['count_auto_margin'] = bcsub($data['count_auto_margin'], $data['count_auto_margin_refund']); + $data['number_auto_margin'] = $number3; + //退回佣金 + $financialType = ['refund_brokerage_two', 'refund_brokerage_one']; + [$data['count_refund_brokerage'], $data['number_refund_brokerage']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + + //佣金 brokerage_one,brokerage_two - 退回佣金 refund_brokerage_two,refund_brokerage_one ) + $number = bcsub($data['number_brokerage'], $data['number_refund_brokerage'], 2); + //平台手续费 =( order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge ) + $number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 2); + + //退回收入 refund_order + 退回佣金 + $number_2 = $data['number_refund']; + $data['count'] = $data['count_brokerage'] + $data['count_refund'] + $data['count_order_charge'] + $data['count_refund_brokerage']+ $data['count_auto_margin']-$data['count_charge']; + $data['number'] = bcadd(bcadd($number3,bcadd($number_2, $number, 2),2), $number_1, 2); + + } else { //平台的 + // 退回 订单实际获得金额 + + $financialType = ['order_true', 'presell_true','auto_margin']; + [$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType); + + $financialType = ['commission_to_entry_merchant']; + [$data['count_merchant'], $data['number_merchant']] = $this->dao->getDataByType($type, $where, $date, $financialType); + $data['count_order']=bcsub($data['count_order'],$data['count_merchant']); + $data['number_order']=bcsub($data['number_order'],$data['number_merchant'], 2); + + + + //付给服务团队和其他的佣金 + [$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date); + [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $commission); + + $data['count_brokerage']+=$data['count_commission']-$data['count_refund']; + $data['number_brokerage']+=$data['number_commission']-$data['number_refund']; + + $number = bcadd($data['number_brokerage'], $data['number_order'], 2); + $number_1 = bcadd($number, $data['number_svipcoupon'], 2); + + $data['count'] = $data['count_brokerage'] + $data['count_order'] + $data['count_charge']; + $data['number'] = bcadd($number_1, $data['number_charge'], 2); + } + return $data; + } + + /** + * TODO 手续费 + * @param $where + * @param $date + * @return mixed + * @author Qinii + * @day 3/24/21 + */ + public function countCharge($type, $where, $date) + { + $financialType = ['order_charge']; + [$count, $number] = $this->dao->getDataByType($type, $where, $date, $financialType); + + return compact('count', 'number'); + } +} diff --git a/app/controller/admin/order/OrderOther.php b/app/controller/admin/order/OrderOther.php new file mode 100644 index 00000000..6939f13a --- /dev/null +++ b/app/controller/admin/order/OrderOther.php @@ -0,0 +1,193 @@ + +// +---------------------------------------------------------------------- + + +namespace app\controller\admin\order; + +use crmeb\basic\BaseController; +use app\common\repositories\store\ExcelRepository; +use app\common\repositories\system\merchant\MerchantRepository; +use app\common\repositories\store\order\StoreOtherOrderRepository as repository; +use app\common\repositories\store\order\StoreGroupOrderOtherRepository; +use crmeb\services\ExcelService; +use think\App; + +class OrderOther extends BaseController +{ + protected $repository; + + public function __construct(App $app, repository $repository) + { + parent::__construct($app); + $this->repository = $repository; + } + + + public function lst($id) + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['date','order_sn','order_type','keywords','username','activity_type','group_order_sn','store_name']); + $where['reconciliation_type'] = $this->request->param('status', 1); + $where['mer_id'] = $id; + return app('json')->success($this->repository->adminMerGetList($where, $page, $limit)); + } + + public function markForm($id) + { + if (!$this->repository->getWhereCount([$this->repository->getPk() => $id])) + return app('json')->fail('数据不存在'); + return app('json')->success(formToData($this->repository->adminMarkForm($id))); + } + + public function mark($id) + { + if (!$this->repository->getWhereCount([$this->repository->getPk() => $id])) + return app('json')->fail('数据不存在'); + $data = $this->request->params(['admin_mark']); + $this->repository->update($id, $data); + return app('json')->success('备注成功'); + } + + public function title() + { + $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type']); + return app('json')->success($this->repository->getStat($where, $where['status'])); + } + /** + * TODO + * @return mixed + * @author Qinii + * @day 2020-06-25 + */ + public function getAllList() + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type','group_order_sn','store_name']); + $data = $this->repository->adminGetList($where, $page, $limit); + return app('json')->success($data); + } + + public function takeTitle() + { + $where = $this->request->params(['date','order_sn','keywords','username','is_trader']); + $where['take_order'] = 1; + $where['status'] = ''; + $where['verify_date'] = $where['date']; + unset($where['date']); + return app('json')->success($this->repository->getStat($where, '')); + } + + + /** + * TODO + * @return mixed + * @author Qinii + * @day 2020-08-17 + */ + public function chart() + { + return app('json')->success($this->repository->OrderTitleNumber(null,null)); + } + + /** + * TODO 自提订单头部统计 + * @return mixed + * @author Qinii + * @day 2020-08-17 + */ + public function takeChart() + { + return app('json')->success($this->repository->OrderTitleNumber(null,1)); + } + + /** + * TODO 订单类型 + * @return mixed + * @author Qinii + * @day 2020-08-15 + */ + public function orderType() + { + return app('json')->success($this->repository->orderType([])); + } + + public function detail($id) + { + $data = $this->repository->getOne($id, null); + if (!$data) + return app('json')->fail('数据不存在'); + return app('json')->success($data); + } + + public function status($id) + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['date','user_type']); + $where['id'] = $id; + return app('json')->success($this->repository->getOrderStatus($where, $page, $limit)); + } + + public function reList($id) + { + [$page, $limit] = $this->getPage(); + $where = ['reconciliation_id' => $id, 'type' => 0]; + return app('json')->success($this->repository->reconList($where, $page, $limit)); + } + + /** + * TODO 导出文件 + * @author Qinii + * @day 2020-07-30 + */ + public function excel() + { + $where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','take_order']); + if($where['take_order']){ + $where['verify_date'] = $where['date']; + unset($where['date']); + } + [$page, $limit] = $this->getPage(); + $data = app()->make(ExcelService::class)->order($where, $page, $limit); + return app('json')->success($data); + } + + /** + * TODO + * @param $id + * @return \think\response\Json + * @author Qinii + * @day 2023/2/22 + */ + public function childrenList($id) + { + $data = $this->repository->childrenList($id, 0); + return app('json')->success($data); + } + + /** + * 财务更新订单 + */ + public function payOrder($id,$images,StoreGroupOrderOtherRepository $groupOrderRepository){ + $groupOrder = $groupOrderRepository->detail((int)$id, false); + if(!$images){ + return app('json')->fail('请上传凭证'); + } + $groupOrder->order_extend=$images; + + $res=$this->repository->paySuccess($groupOrder); + if($res){ + return app('json')->success('操作成功'); + }else{ + return app('json')->fail('操作失败'); + } + } +} diff --git a/app/controller/admin/store/StoreProduct.php b/app/controller/admin/store/StoreProduct.php index e07842da..2255b2ef 100644 --- a/app/controller/admin/store/StoreProduct.php +++ b/app/controller/admin/store/StoreProduct.php @@ -85,7 +85,7 @@ class StoreProduct extends BaseController */ public function getStatusFilter() { - return app('json')->success($this->repository->getFilter(null,'商品',0)); + return app('json')->success($this->repository->getFilter(null,'商品',[0,98])); } /** diff --git a/app/controller/admin/system/config/Config.php b/app/controller/admin/system/config/Config.php index 7a8f963b..c8ba83eb 100644 --- a/app/controller/admin/system/config/Config.php +++ b/app/controller/admin/system/config/Config.php @@ -216,7 +216,6 @@ class Config extends BaseController { $file = $this->request->file($field); if (!$file) return app('json')->fail('请上传附件'); - //ico 图标处理 if ($file->getOriginalExtension() == 'ico') { $file->move('public','favicon.ico'); @@ -224,7 +223,7 @@ class Config extends BaseController return app('json')->success(['src' => $res]); } - $upload = UploadService::create(1); + $upload = UploadService::create(); $data = $upload->to('attach')->validate()->move($field); if ($data === false) { return app('json')->fail($upload->getError()); diff --git a/app/controller/admin/system/merchant/FinancialRecordTransfer.php b/app/controller/admin/system/merchant/FinancialRecordTransfer.php new file mode 100644 index 00000000..5eb89753 --- /dev/null +++ b/app/controller/admin/system/merchant/FinancialRecordTransfer.php @@ -0,0 +1,171 @@ + +// +---------------------------------------------------------------------- + + +namespace app\controller\admin\system\merchant; + + +use app\common\repositories\store\ExcelRepository; +use app\common\repositories\system\merchant\FinancialRecordTransferRepository; +use crmeb\basic\BaseController; +use crmeb\services\ExcelService; +use think\App; + +class FinancialRecordTransfer extends BaseController +{ + protected $repository; + + public function __construct(App $app, FinancialRecordTransferRepository $repository) + { + parent::__construct($app); + $this->repository = $repository; + } + + public function lst() + { + halt(1); + + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['keyword', 'date', 'mer_id']); + $merId = $this->request->merId(); + if ($merId) { + $where['mer_id'] = $merId; + $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon', + 'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund','commission_to_entry_merchant','commission_to_entry_merchant_refund' + ,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund']; + } else { + $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon', + 'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund' + ,'commission_to_entry_merchant','commission_to_entry_merchant_refund' + ,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund']; + } + return app('json')->success($this->repository->getList($where, $page, $limit)); + } + + public function export() + { + $where = $this->request->params(['keyword', 'date', 'mer_id']); + $merId = $this->request->merId(); + if ($merId) { + $where['mer_id'] = $merId; + $where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon']; + } else { + $where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon','order_svip_coupon']; + } + + [$page, $limit] = $this->getPage(); + $data = app()->make(ExcelService::class)->financial($where,$page,$limit); + return app('json')->success($data); + } + + + /** + * TODO 头部统计 + * @return \think\response\Json + * @author Qinii + * @day 3/23/21 + */ + public function getTitle() + { + $where = $this->request->params(['date']); + $where['is_mer'] = $this->request->merId() ?? 0 ; + if($where['is_mer'] == 0){ + $data = $this->repository->getAdminTitle($where); + }else{ + $data = $this->repository->getMerchantTitle($where); + } + return app('json')->success($data); + } + + + /** + * TODO 列表 + * @return \think\response\Json + * @author Qinii + * @day 3/23/21 + */ + public function getList() + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params([['type',1],'date']); + $where['is_mer'] = $this->request->merId() ?? 0 ; + try { + $merchant = $this->request->merchant(); + }catch (\Exception $e){ + $merchant = []; + } + $data = $this->repository->getAdminList($where,$page, $limit,$merchant); + return app('json')->success($data); + } + + + /** + * TODO 详情 + * @param $type + * @return \think\response\Json + * @author Qinii + * @day 3/23/21 + */ + public function detail($type) + { + $date = $this->request->param('date'); + $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ; + $where['is_mer'] = $this->request->merId() ?? 0 ; + if($this->request->merId()){ + $merchant = $this->request->merchant(); + $data = $this->repository->merDetail($type,$where,$merchant); + }else{ + $data = $this->repository->adminDetail($type,$where); + } + + return app('json')->success($data); + } + + /** + * TODO 导出文件 + * @param $type + * @author Qinii + * @day 3/25/21 + */ + public function exportDetail($type) + { + [$page, $limit] = $this->getPage(); + $date = $this->request->param('date'); + $where['date'] = empty($date) ? date('Y-m-d',time()) : $date ; + $where['type'] = $type; + $where['is_mer'] = $this->request->merId() ?? 0 ; + try { + $merchant = $this->request->merchant(); + }catch (\Exception $e){ + $merchant = []; + } + $data = app()->make(ExcelService::class)->exportFinancial($where,$page,$limit,$merchant); +// app()->make(ExcelRepository::class)->create($where, $this->request->adminId(), 'exportFinancial',$where['is_mer']); + return app('json')->success($data); + } + + /** + * TODO 流水统计 + * @return \think\response\Json + * @author Qinii + * @day 5/7/21 + */ + public function title() + { + $where = $this->request->params(['date']); + +// $data = $this->repository->getFiniancialTitle($this->request->merId(),$where); + $data = []; + return app('json')->success($data); + } + +} diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index f697f7b9..86dfd516 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -1608,11 +1608,20 @@ class Auth extends BaseController 'fail_msg' => $remark ]; Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 2)->update($updData); - $merId = Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 2)->value('mer_id', 0); - Db::name('merchant')->where('mer_id', $merId)->where('status', 1)->update(['business_status' => ($status == 1 ? 2 : 3)]); - if ($status == 1) { - Db::name('merchant')->where('mer_id', $merId)->update(['mer_settlement_agree_status' => 1]); + $merchant_intention = Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 2)->find(); + if($merchant_intention){ + if ($status == 1) { + $datas['business_status']=2; + $datas['mer_settlement_agree_status']=1; + $datas['financial_bank']=json_encode(['name'=>$merchant_intention['company_name'], + 'bank_code'=>$merchant_intention['bank_code'],'bank'=>$merchant_intention['bank_username'],'bank_branch'=>$merchant_intention['bank_opening']]); + }else{ + $datas['business_status']=3; + } + Db::name('merchant')->where('mer_id', $merchant_intention['mer_id'])->where('status', 1)->update($datas); } + + } return app('json')->success('同步成功'); diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index 1ba6ea6d..fccbf30d 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -57,6 +57,7 @@ use AlibabaCloud\Tea\Utils\Utils; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\SDK\Ocr\V20191230\Models\RecognizeBusinessLicenseRequest; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; + /** * Class Common * @package app\controller\api @@ -110,7 +111,7 @@ class Common extends BaseController public function config() { - $config = systemConfig(['open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status','community_reply_status','community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth','hot_ranking_switch','svip_switch_status','margin_ico','margin_ico_switch']); + $config = systemConfig(['open_update_info', 'store_street_theme', 'is_open_service', 'is_phone_login', 'global_theme', 'integral_status', 'mer_location', 'alipay_open', 'hide_mer_status', 'mer_intention_open', 'share_info', 'share_title', 'share_pic', 'store_user_min_recharge', 'recharge_switch', 'balance_func_status', 'yue_pay_status', 'site_logo', 'routine_logo', 'site_name', 'login_logo', 'procudt_increase_status', 'sys_extension_type', 'member_status', 'copy_command_status', 'community_status', 'community_reply_status', 'community_app_switch', 'withdraw_type', 'recommend_switch', 'member_interests_status', 'beian_sn', 'community_reply_auth', 'hot_ranking_switch', 'svip_switch_status', 'margin_ico', 'margin_ico_switch']); $make = app()->make(TemplateMessageRepository::class); $cache = app()->make(CacheRepository::class)->search(['copyright_status', 'copyright_context', 'copyright_image', 'sys_intention_agree']); @@ -191,7 +192,7 @@ class Common extends BaseController public function wechatNotify() { try { - if($this->request->header('content-type') === 'application/json'){ + if ($this->request->header('content-type') === 'application/json') { return response(WechatService::create()->handleNotifyV3()->getContent()); } return response(WechatService::create()->handleNotify()->getContent()); @@ -231,12 +232,12 @@ class Common extends BaseController public function routineNotify() { try { - if($this->request->header('content-type') === 'application/json'){ + if ($this->request->header('content-type') === 'application/json') { return response(MiniProgramService::create()->handleNotifyV3()->getContent()); } return response(MiniProgramService::create()->handleNotify()->getContent()); } catch (Exception $e) { - Log::info('支付回调失败:' . var_export([$e->getMessage(), $e->getFile() . ':' . $e->getLine(),$this->request->header()], true)); + Log::info('支付回调失败:' . var_export([$e->getMessage(), $e->getFile() . ':' . $e->getLine(), $this->request->header()], true)); } } @@ -477,9 +478,9 @@ class Common extends BaseController if ($user && $user['wechat_user_id']) { $wechatUserService = app()->make(WechatUserRepository::class); $subscribe = $wechatUserService->getWhereCount([ - 'wechat_user_id' => $user['wechat_user_id'], - 'subscribe' => 1 - ]) > 0; + 'wechat_user_id' => $user['wechat_user_id'], + 'subscribe' => 1 + ]) > 0; return app('json')->success(['subscribe' => $subscribe]); } } @@ -487,36 +488,39 @@ class Common extends BaseController } //区县数据 - public function get_area($city_code){ - $select=Db::name('geo_area')->where('city_code',$city_code)->field('area_id id,area_code code,area_name name')->select(); + public function get_area($city_code) + { + $select = Db::name('geo_area')->where('city_code', $city_code)->field('area_id id,area_code code,area_name name')->select(); return app('json')->success($select); } //街道 乡镇数据 - public function get_street($area_code){ - $select=Db::name('geo_street')->where('area_code',$area_code)->field('street_id id,street_code code,street_name name')->select(); - $arr=$select?$select->toArray():[]; - foreach ($arr as $k=>$item){ + public function get_street($area_code) + { + $select = Db::name('geo_street')->where('area_code', $area_code)->field('street_id id,street_code code,street_name name')->select(); + $arr = $select ? $select->toArray() : []; + foreach ($arr as $k => $item) { $first_char = mb_str_split($item['name']); - if($first_char[0]){ - $pinyin=new Pinyin(); - $string=$first_char[0]; + if ($first_char[0]) { + $pinyin = new Pinyin(); + $string = $first_char[0]; $pinyin = $pinyin->abbr($string); - $arr[$k]['pinyin']=$pinyin; - }else{ - $arr[$k]['pinyin']=''; + $arr[$k]['pinyin'] = $pinyin; + } else { + $arr[$k]['pinyin'] = ''; } - } return app('json')->success($arr); } //村数据 - public function get_village($street_code){ - $select=Db::name('geo_village')->where('street_code',$street_code)->field('village_id id,village_code code,village_name name')->select(); + public function get_village($street_code) + { + $select = Db::name('geo_village')->where('street_code', $street_code)->field('village_id id,village_code code,village_name name')->select(); return app('json')->success($select); } //获取云店铺 - public function get_cloud_shop($street_code){ + public function get_cloud_shop($street_code) + { //更新查询镇级供应链店铺 // $typeTownSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownSupplyChain'])->value('mer_type_id'); /* @@ -529,34 +533,35 @@ class Common extends BaseController ->join('merchant_category c','m.category_id=c.merchant_category_id') ->field('m.mer_id,category_id,category_name,c.background,c.cover,c.description')->select(); */ - $find=DB::name('merchant_category') - ->where('cover', '<>' ,'') + $find = DB::name('merchant_category') + ->where('cover', '<>', '') ->field('merchant_category_id as category_id,category_name,background,cover,description')->select(); - return app('json')->success($find??[]); + return app('json')->success($find ?? []); } /** * 查询组合数据 */ - public function system_group_value($name){ - $group_id= Db::name('system_group')->where('group_key',$name)->value('group_id'); - $data=[]; - if($group_id){ - $select=Db::name('system_group_data')->where('group_id',$group_id) - ->limit(100)->select(); - foreach($select as $k=>$v){ - $data[$k]=json_decode($v['value'],true); + public function system_group_value($name) + { + $group_id = Db::name('system_group')->where('group_key', $name)->value('group_id'); + $data = []; + if ($group_id) { + $select = Db::name('system_group_data')->where('group_id', $group_id) + ->limit(100)->select(); + foreach ($select as $k => $v) { + $data[$k] = json_decode($v['value'], true); } - } - return app('json')->success($data); - + } + return app('json')->success($data); } - /** - * - * 商户营业执照 - */ - public function merchant_license_identify($image){ + /** + * + * 商户营业执照 + */ + public function merchant_license_identify($image) + { $config = new Config([ // 必填,您的 AccessKey ID "accessKeyId" => 'LTAI5t7mhH3ij2cNWs1zhPmv', @@ -565,36 +570,33 @@ class Common extends BaseController ]); // Endpoint 请参考 https://api.aliyun.com/product/ocr $config->endpoint = "ocr.cn-shanghai.aliyuncs.com"; - $client= new Ocr($config); + $client = new Ocr($config); $recognizeBusinessLicenseRequest = new RecognizeBusinessLicenseRequest([ "imageURL" => $image ]); $runtime = new RuntimeOptions([]); try { // 复制代码运行请自行打印 API 的返回值 - $resp=$client->recognizeBusinessLicenseWithOptions($recognizeBusinessLicenseRequest, $runtime); - $a= Utils::toArray($resp->body); - $data=[]; - if($a){ - $data['address']=$a['Data']['Address']; - $data['business']=$a['Data']['Business']; - $data['legal_person']=$a['Data']['LegalPerson']; - $data['name']=$a['Data']['Name']; - $data['register_number']=$a['Data']['RegisterNumber']; - $data['type']=$a['Data']['Type']; + $resp = $client->recognizeBusinessLicenseWithOptions($recognizeBusinessLicenseRequest, $runtime); + $a = Utils::toArray($resp->body); + $data = []; + if ($a) { + $data['address'] = $a['Data']['Address']; + $data['business'] = $a['Data']['Business']; + $data['legal_person'] = $a['Data']['LegalPerson']; + $data['name'] = $a['Data']['Name']; + $data['register_number'] = $a['Data']['RegisterNumber']; + $data['type'] = $a['Data']['Type']; } return app('json')->success($data); - - } - catch (Exception $error) { + } catch (Exception $error) { if (!($error instanceof TeaError)) { $error = new TeaError([], $error->getMessage(), $error->getCode(), $error); } - $a=Utils::assertAsString($error->message); + $a = Utils::assertAsString($error->message); return app('json')->fail($a); - } - } + } /** * 商品标签 @@ -603,7 +605,23 @@ class Common extends BaseController { [$page, $limit] = $this->getPage(); $where = $this->request->params(['name', 'type', 'status']); - $data = $repository->getList($where,$page, $limit); + $data = $repository->getList($where, $page, $limit); return app('json')->success($data); } + + /** + * 小程序版本 + */ + public function applet() + { + $group_id = Db::name('system_group')->where('group_key', 'applet')->value('group_id'); + $list = []; + if ($group_id) { + $select = Db::name('system_group_data')->where('group_id', $group_id)->field('value')->limit(30)->where('status',1)->select(); + foreach ($select as $key => $value) { + $list[] = json_decode($value['value'], true); + } + } + return app('json')->success($list); + } } diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index 49fb89e8..571d5182 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -405,4 +405,16 @@ class StoreOrder extends BaseController return app('json')->success($list); } + + /** + * 获取商户押金列表 + */ + public function getOrderAutoMarginList($merId){ + [$page, $limit] = $this->getPage(); + $select= Db::name('financial_record')->where('mer_id',$merId)->where('type',1) + ->where('financial_type','auto_margin')->where('financial_pm',0) + ->page($page)->limit($limit)->order('financial_record_id','desc')->select(); + return app('json')->success($select); + + } } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index cbbcb097..df132182 100755 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -310,7 +310,7 @@ class Merchant extends BaseController public function apply($merId) { - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,ot_margin')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } @@ -319,7 +319,6 @@ class Merchant extends BaseController $_line = bcsub($merchant->mer_money, $extract_minimum_line, 2); $_extract = ($_line < 0) ? 0 : $_line; $merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($merId); - $data = [ 'mer_id' => $merchant->mer_id, //商户id 'mer_name' => $merchant->mer_name, //商户名称 @@ -329,11 +328,13 @@ class Merchant extends BaseController 'extract_minimum_line' => $extract_minimum_line, //提现最低额度 'extract_minimum_num' => $extract_minimum_num, //提现最低次数 'extract_money' => $_extract, //可提现金额 - 'financial_bank_name' => $merchant->financial_bank->name ?? '', //银行卡信息 - 'financial_bank_bank' => $merchant->financial_bank->bank ?? '', //银行卡信息 - 'financial_bank_code' => $merchant->financial_bank->bank_code ?? '', //银行卡信息 - 'financial_bank_branch' => $merchant->financial_bank->bank_branch ?? '', //开户行 + 'financial_bank_name' => $merchant->financial_bank->name ?? '', //银行账户姓名 + 'financial_bank_bank' => $merchant->financial_bank->bank ?? '', //开户行 + 'financial_bank_code' => $merchant->financial_bank->bank_code ?? '', //银行账号 + 'financial_bank_branch' => $merchant->financial_bank->bank_branch ?? '', //开户行地址 'financial_type' => $merchant->financial_type, //提现方式 + 'ot_margin' => $merchant->ot_margin, //提现方式 + ]; return app('json')->success($data); } diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index b5ec4edf..196a4e31 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -68,8 +68,6 @@ class MerchantIntention extends BaseController $adminRepository = app()->make(MerchantAdminRepository::class); if ($adminRepository->fieldExists('account', $data['phone'])) throw new ValidateException('手机号已是管理员,不可申请'); - // 数据表的village_id为int型,前端传的是village_code,可能超过11位,int最大可存储11位,导致sql报错。 转换为主键id存储 - $data['village_id'] = Db::name('geo_village')->where('village_code', $data['village_id'])->value('village_id'); $intention = $this->repository->create($data); SwooleTaskService::admin('notice', [ 'type' => 'new_intention', diff --git a/app/controller/api/store/order/StoreOrderOther.php b/app/controller/api/store/order/StoreOrderOther.php index 052d53e8..ab879fdc 100644 --- a/app/controller/api/store/order/StoreOrderOther.php +++ b/app/controller/api/store/order/StoreOrderOther.php @@ -16,7 +16,6 @@ namespace app\controller\api\store\order; use app\common\model\store\order\StoreGroupOrder; use app\common\repositories\delivery\DeliveryOrderRepository; -use app\common\repositories\store\order\StoreOrderCreateRepository; use app\common\repositories\store\order\StoreOtherOrderCreateRepository; use app\common\repositories\store\order\StoreOrderReceiptRepository; use app\validate\api\UserReceiptValidate; @@ -56,7 +55,7 @@ class StoreOrderOther extends BaseController $this->repository = $repository; } - public function v2CheckOrder(StoreCartRepository $cartRepository, StoreOrderCreateRepository $orderCreateRepository) + public function v2CheckOrder(StoreCartRepository $cartRepository, StoreOtherOrderCreateRepository $orderCreateRepository) { $cartId = (array)$this->request->param('cart_id', []); $addressId = (int)$this->request->param('address_id'); @@ -268,19 +267,6 @@ class StoreOrderOther extends BaseController return app('json')->success(['qrcode' => $this->repository->wxQrcode($id, $order->verify_code)]); } - /** - * 生成二维码 - */ - public function logisticsCode($id) - { - $storeInfo = Db::name('store_service')->where('uid', $this->request->uid())->find(); - if (!$storeInfo) - return app('json')->fail('商户信息有误'); - $order = $this->repository->getWhere(['order_id' => $id, 'mer_id' => $storeInfo['mer_id'], 'is_del' => 0]); - if (!$order) - return app('json')->fail('订单状态有误'); - return app('json')->success(['qrcode' => $this->repository->logisticsQrcode($id, $order->order_sn)]); - } public function del($id) { diff --git a/app/controller/merchant/store/order/OrderOther.php b/app/controller/merchant/store/order/OrderOther.php index e5d58133..c2f33406 100644 --- a/app/controller/merchant/store/order/OrderOther.php +++ b/app/controller/merchant/store/order/OrderOther.php @@ -58,6 +58,7 @@ class OrderOther extends BaseController [$page, $limit] = $this->getPage(); $where = $this->request->params(['status', 'date', 'order_sn', 'username', 'order_type', 'keywords', 'order_id', 'activity_type', 'group_order_sn', 'store_name']); $where['mer_id'] = $this->request->merId(); + $where['paid']=1; return app('json')->success($this->repository->merchantGetList($where, $page, $limit)); } diff --git a/config/upload.php b/config/upload.php index e1f5a6ce..4b28e997 100644 --- a/config/upload.php +++ b/config/upload.php @@ -19,9 +19,9 @@ return [ //上传文件大小 'filesize' => 52428800, //上传文件后缀类型 - 'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa','wgt'], + 'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa','wgt','zip'], //上传文件类型 - 'fileMime' => ['image/jpeg', 'image/gif', 'image/png', 'text/plain', 'audio/mpeg', 'image/vnd.microsoft.icon'], + 'fileMime' => ['image/jpeg', 'image/gif', 'image/png', 'text/plain', 'audio/mpeg', 'image/vnd.microsoft.icon','application/widget','application/zip'], //驱动模式 'stores' => [ //本地上传配置 diff --git a/crmeb/jobs/SendSmsJob.php b/crmeb/jobs/SendSmsJob.php index 37482466..e0664674 100644 --- a/crmeb/jobs/SendSmsJob.php +++ b/crmeb/jobs/SendSmsJob.php @@ -27,8 +27,6 @@ class SendSmsJob implements JobInterface public function fire($job, $data) { - $backtrace = debug_backtrace(); - Log::info("函数SendSmsJob被". $backtrace[1]['function'] . "调用\n"); $status = app()->make(SystemNoticeConfigRepository::class)->getNoticeStatusByConstKey($data['tempId']); if (!$status) { $job->delete(); @@ -40,7 +38,7 @@ class SendSmsJob implements JobInterface $client->send($data['tempId'], $data); } catch (\Exception $e) { Log::info('JgPush推送消息发送失败' . json_encode($data) . ' - ' . $e->getMessage()); - DingTalk::exception($e, 'JgPush推送消息发送失败' . var_export($data, 1)); + // DingTalk::exception($e, 'JgPush推送消息发送失败' . var_export($data, 1)); } } if ($status['notice_sms'] == 1) { diff --git a/crmeb/listens/RefundOrderAgreeListen.php b/crmeb/listens/RefundOrderAgreeListen.php index 400805b2..2013ee2a 100644 --- a/crmeb/listens/RefundOrderAgreeListen.php +++ b/crmeb/listens/RefundOrderAgreeListen.php @@ -33,7 +33,7 @@ class RefundOrderAgreeListen extends TimerService implements ListenerInterface try { $make->adminRefund($id); } catch (\Exception $e) { - Log::info('自动退款失败' . var_export($id, true)); + Log::info('自动退款失败' . $e->getMessage()); } } }); diff --git a/crmeb/services/SmsService.php b/crmeb/services/SmsService.php index b2c421ff..edd26381 100644 --- a/crmeb/services/SmsService.php +++ b/crmeb/services/SmsService.php @@ -55,7 +55,7 @@ class SmsService */ public function checkSmsCode($phone, $code, $type) { - if (!env('DEVELOPMENT',false)) { + if (!env('DEVELOPMENT', false)) { $sms_key = $this->sendSmsKey($phone, $type); if (!$cache_code = Cache::get($sms_key)) return false; if ($code != $cache_code) return false; @@ -233,7 +233,7 @@ class SmsService //到货提醒通知 2.1 case 'PRODUCT_INCREASE': $product = app()->make(ProductRepository::class)->getWhere(['product_id' => $id], '*', ['attrValue']); - if (!$product) return ; + if (!$product) return; $unique[] = 1; foreach ($product['attrValue'] as $item) { if ($item['stock'] > 0) $unique[] = $item['unique']; @@ -241,7 +241,7 @@ class SmsService $make = app()->make(ProductTakeRepository::class); $query = $make->getSearch(['product_id' => $id, 'status' => 0, 'type' => 1])->where('unique', 'in', $unique); $ret = $query->select(); - if (!$ret) return ; + if (!$ret) return; foreach ($ret as $item) { if ($item->user->phone) { self::create()->send($item->user->phone, $tempId, [ @@ -280,11 +280,14 @@ class SmsService break; //付费会员支付成功 case 'SVIP_PAY_SUCCESS': - self::create()->send($id['phone'], $tempId, ['store_name' => systemConfig('site_name'),'date' => $id['date']]); + self::create()->send($id['phone'], $tempId, ['store_name' => systemConfig('site_name'), 'date' => $id['date']]); break; case 'MERCHANT_CREDIT_BUY_NOTICE': self::sendMerMessage($id, $tempId, ['order_id' => $data['orderId']]); break; + case 'ORDER_CREATE': + self::create()->send($data['phone'], $tempId, ['name' => $data['orderId']]); + break; } } @@ -297,6 +300,4 @@ class SmsService $yunxinSmsService->send($service['phone'], $tempId, array_merge(['admin_name' => $service['nickname']], $data)); } } - - } diff --git a/public/mer.html b/public/mer.html index 37140559..d46e055c 100644 --- a/public/mer.html +++ b/public/mer.html @@ -1 +1 @@ -