diff --git a/addon/activity/api/controller/Goods.php b/addon/activity/api/controller/Goods.php deleted file mode 100644 index a2903e2..0000000 --- a/addon/activity/api/controller/Goods.php +++ /dev/null @@ -1,139 +0,0 @@ -params[ 'id' ]) ? $this->params[ 'id' ] : 0; - if (empty($activity_id)) { - return $this->response($this->error('', '活动不存在活已过期')); - } - $groupbuy_model = new ActivityModel(); - $condition = [ - [ 'activity_id', '=', $activity_id ], - [ 'site_id', '=', $this->site_id ], - ]; - $goods_sku_detail = $groupbuy_model->getActivityInfo($condition)[ 'data' ]; - - if (empty($goods_sku_detail)) return $this->response($this->error()); - $goods_sku_detail['goods_name']='这个超级优惠券'; - $goods_sku_detail['sku_images']=$goods_sku_detail['activity_image']; - $goods_sku_detail['goods_service_ids']=[]; - $goods_sku_detail['goods_content']=$goods_sku_detail['content']; - $goods_sku_detail['goods_stock']=9999; - $goods_sku_detail['goods_state']=1; - $res[ 'goods_sku_detail' ] = $goods_sku_detail; - // 处理公共数据 - $goods_sku_api = new Goodssku(); - $goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ]); - return $this->response($this->success($res)); - } - - /** - * 查询商品SKU集合 - * @return false|string - */ - public function goodsSku() - { - $goods_id = isset($this->params[ 'goods_id' ]) ? $this->params[ 'goods_id' ] : 0; - $groupbuy_id = isset($this->params[ 'groupbuy_id' ]) ? $this->params[ 'groupbuy_id' ] : 0; - if (empty($goods_id)) { - return $this->response($this->error('', 'REQUEST_ID')); - } - if (empty($groupbuy_id)) { - return $this->response($this->error('', 'REQUEST_GROUPBUY_ID')); - } - $groupbuy_model = new GroupbuyModel(); - $condition = [ - [ 'pg.groupbuy_id', '=', $groupbuy_id ], - [ 'pg.site_id', '=', $this->site_id ], - [ 'g.goods_id', '=', $goods_id ], - [ 'g.goods_state', '=', 1 ], - [ 'g.is_delete', '=', 0 ] - ]; - $list = $groupbuy_model->getGroupbuyGoodsSkuList($condition, null); - return $this->response($list); - } - - public function page() - { - $page = isset($this->params[ 'page' ]) ? $this->params[ 'page' ] : 1; - $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS; - $goods_id_arr = isset($this->params[ 'goods_id_arr' ]) ? $this->params[ 'goods_id_arr' ] : '';//goods_id数组 - - $condition = [ - [ 'pg.status', '=', 2 ],// 状态(1未开始 2进行中 3已结束) - [ 'g.goods_stock', '>', 0 ], - [ 'g.goods_state', '=', 1 ], - [ 'g.is_delete', '=', 0 ], - [ 'sku.site_id', '=', $this->site_id ] - ]; - - if (!empty($goods_id_arr)) { - $condition[] = [ 'sku.goods_id', 'in', $goods_id_arr ]; - } - - $groupbuy_model = new GroupbuyModel(); - $list = $groupbuy_model->getGroupbuyGoodsPageList($condition, $page, $page_size, 'pg.groupbuy_id desc'); - - return $this->response($list); - } - - public function lists() - { - $num = isset($this->params[ 'num' ]) ? $this->params[ 'num' ] : 0; - - $condition = [ - [ 'pg.status', '=', 2 ],// 状态(1未开始 2进行中 3已结束) - [ 'g.goods_stock', '>', 0 ], - [ 'g.goods_state', '=', 1 ], - [ 'g.is_delete', '=', 0 ], - [ 'sku.site_id', '=', $this->site_id ] - ]; - - if (!empty($goods_id_arr)) { - $condition[] = [ 'sku.goods_id', 'in', $goods_id_arr ]; - } - - $groupbuy_model = new GroupbuyModel(); - $list = $groupbuy_model->getGroupbuyGoodsList($condition, '', 'pg.groupbuy_id desc', $num); - - return $this->response($list); - } - - /** - * 获取商品海报 - */ - public function poster() - { - $this->checkToken(); - - $promotion_type = 'groupbuy'; - $qrcode_param = json_decode($this->params[ 'qrcode_param' ], true); - $qrcode_param[ 'source_member' ] = $this->member_id; - $qrcode_param[ 'id' ] = $qrcode_param[ 'groupbuy_id' ] ?? 0; - unset($qrcode_param[ 'groupbuy_id' ]); - $poster = new Poster(); - $res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id); - return $this->response($res); - } -} diff --git a/addon/activity/api/controller/Ordercreate.php b/addon/activity/api/controller/Ordercreate.php deleted file mode 100644 index df74088..0000000 --- a/addon/activity/api/controller/Ordercreate.php +++ /dev/null @@ -1,189 +0,0 @@ -checkToken(); - if ($token[ 'code' ] < 0) return $this->response($token); - $order_create = new OrderCreateModel(); - $data = [ - 'groupbuy_id' => isset($this->params[ 'groupbuy_id' ]) ? $this->params[ 'groupbuy_id' ] : '',//团购id - 'num' => isset($this->params[ 'num' ]) ? $this->params[ 'num' ] : 1,//商品数量(买几套) - 'sku_id' => isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0,//sku_id - 'site_id' => $this->site_id,//站点id - 'member_id' => $this->member_id, - 'is_balance' => isset($this->params[ 'is_balance' ]) ? $this->params[ 'is_balance' ] : 0,//是否使用余额 - 'pay_password' => isset($this->params[ 'pay_password' ]) ? $this->params[ 'pay_password' ] : '',//支付密码 - 'order_from' => $this->params[ 'app_type' ], - 'order_from_name' => $this->params[ 'app_type_name' ], - 'buyer_message' => $this->params[ 'buyer_message' ] ?? '', - 'delivery' => isset($this->params[ "delivery" ]) && !empty($this->params[ "delivery" ]) ? json_decode($this->params[ "delivery" ], true) : [], - 'member_address' => isset($this->params[ "member_address" ]) && !empty($this->params[ "member_address" ]) ? json_decode($this->params[ "member_address" ], true) : [], - - 'latitude' => $this->params[ "latitude" ] ?? '', - 'longitude' => $this->params[ "longitude" ] ?? '', - - 'is_invoice' => $this->params[ "is_invoice" ] ?? 0, - 'invoice_type' => $this->params[ "invoice_type" ] ?? 0, - 'invoice_title' => $this->params[ "invoice_title" ] ?? '', - 'taxpayer_number' => $this->params[ "taxpayer_number" ] ?? '', - 'invoice_content' => $this->params[ "invoice_content" ] ?? '', - 'invoice_full_address' => $this->params[ "invoice_full_address" ] ?? '', - 'is_tax_invoice' => $this->params[ "is_tax_invoice" ] ?? 0, - 'invoice_email' => $this->params[ "invoice_email" ] ?? '', - 'invoice_title_type' => $this->params[ "invoice_title_type" ] ?? 0, - 'buyer_ask_delivery_time' => $this->params[ "buyer_ask_delivery_time" ] ?? '', - 'form_data' => isset($this->params[ "form_data" ]) && !empty($this->params[ "form_data" ]) ? json_decode($this->params[ "form_data" ], true) : [], - ]; - if (empty($data[ 'sku_id' ]) || empty($data[ 'groupbuy_id' ])) { - return $this->response($this->error('', '缺少必填参数商品数据')); - } - if ($data[ 'num' ] < 1) { - return $this->response($this->error('', '购买数量不能小于1')); - } - $res = $order_create->create($data); - return $this->response($res); - } - - /** - * 门店自提情况下提交订单验证地址和门店库存 - */ - public function verifyAreaOrStock() - { - $token = $this->checkToken(); - if ($token[ 'code' ] < 0) return $this->response($token); - $order_create = new OrderCreateModel(); - $data = [ - 'groupbuy_id' => isset($this->params[ 'groupbuy_id' ]) ? $this->params[ 'groupbuy_id' ] : '',//团购id - 'num' => isset($this->params[ 'num' ]) ? $this->params[ 'num' ] : 1,//商品数量(买几套) - 'sku_id' => isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0,//sku_id - 'site_id' => $this->site_id,//站点id - 'member_id' => $this->member_id, - 'is_balance' => isset($this->params[ 'is_balance' ]) ? $this->params[ 'is_balance' ] : 0,//是否使用余额 - 'pay_password' => isset($this->params[ 'pay_password' ]) ? $this->params[ 'pay_password' ] : '',//支付密码 - 'order_from' => $this->params[ 'app_type' ], - 'order_from_name' => $this->params[ 'app_type_name' ], - 'buyer_message' => $this->params[ 'buyer_message' ] ?? '', - 'delivery' => isset($this->params[ "delivery" ]) && !empty($this->params[ "delivery" ]) ? json_decode($this->params[ "delivery" ], true) : [], - 'member_address' => isset($this->params[ "member_address" ]) && !empty($this->params[ "member_address" ]) ? json_decode($this->params[ "member_address" ], true) : [], - - 'latitude' => $this->params[ "latitude" ] ?? '', - 'longitude' => $this->params[ "longitude" ] ?? '', - - 'is_invoice' => $this->params[ "is_invoice" ] ?? 0, - 'invoice_type' => $this->params[ "invoice_type" ] ?? 0, - 'invoice_title' => $this->params[ "invoice_title" ] ?? '', - 'taxpayer_number' => $this->params[ "taxpayer_number" ] ?? '', - 'invoice_content' => $this->params[ "invoice_content" ] ?? '', - 'invoice_full_address' => $this->params[ "invoice_full_address" ] ?? '', - 'is_tax_invoice' => $this->params[ "is_tax_invoice" ] ?? 0, - 'invoice_email' => $this->params[ "invoice_email" ] ?? '', - 'invoice_title_type' => $this->params[ "invoice_title_type" ] ?? 0, - 'buyer_ask_delivery_time' => $this->params[ "buyer_ask_delivery_time" ] ?? '', - ]; - if (empty($data[ 'sku_id' ]) || empty($data[ 'groupbuy_id' ])) { - return $this->response($this->error('', '缺少必填参数商品数据')); - } - $res = $order_create->verifyAreaOrStock($data); - return $this->response($res); - } - - /** - * 计算信息 - */ - public function calculate() - { - $token = $this->checkToken(); - if ($token[ 'code' ] < 0) return $this->response($token); - $order_create = new OrderCreateModel(); - $data = [ - 'groupbuy_id' => isset($this->params[ 'groupbuy_id' ]) ? $this->params[ 'groupbuy_id' ] : '',//团购id - 'num' => isset($this->params[ 'num' ]) ? $this->params[ 'num' ] : 1,//商品数量(买几套) - 'sku_id' => isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0,//sku_id - 'member_id' => $this->member_id, - 'site_id' => $this->site_id,//站点id - 'is_balance' => isset($this->params[ 'is_balance' ]) ? $this->params[ 'is_balance' ] : 0,//是否使用余额 - 'order_from' => $this->params[ 'app_type' ], - 'order_from_name' => $this->params[ 'app_type_name' ], - 'delivery' => isset($this->params[ "delivery" ]) && !empty($this->params[ "delivery" ]) ? json_decode($this->params[ "delivery" ], true) : [], - 'member_address' => isset($this->params[ "member_address" ]) && !empty($this->params[ "member_address" ]) ? json_decode($this->params[ "member_address" ], true) : [], - - 'latitude' => $this->params[ "latitude" ] ?? '', - 'longitude' => $this->params[ "longitude" ] ?? '', - - 'is_invoice' => $this->params[ "is_invoice" ] ?? 0, - 'invoice_type' => $this->params[ "invoice_type" ] ?? 0, - 'invoice_title' => $this->params[ "invoice_title" ] ?? '', - 'taxpayer_number' => $this->params[ "taxpayer_number" ] ?? '', - 'invoice_content' => $this->params[ "invoice_content" ] ?? '', - 'invoice_full_address' => $this->params[ "invoice_full_address" ] ?? '', - 'is_tax_invoice' => $this->params[ "is_tax_invoice" ] ?? 0, - 'invoice_email' => $this->params[ "invoice_email" ] ?? '', - 'invoice_title_type' => $this->params[ "invoice_title_type" ] ?? 0, - 'buyer_ask_delivery_time' => $this->params[ "buyer_ask_delivery_time" ] ?? '', - ]; - if (empty($data[ 'sku_id' ]) || empty($data[ 'groupbuy_id' ])) { - return $this->response($this->error('', '缺少必填参数商品数据')); - } - $res = $order_create->calculate($data); - return $this->response($this->success($res)); - } - - /** - * 待支付订单 数据初始化 - * @return string - */ - public function payment() - { - $token = $this->checkToken(); - if ($token[ 'code' ] < 0) return $this->response($token); - $order_create = new OrderCreateModel(); - $data = [ - 'groupbuy_id' => isset($this->params[ 'groupbuy_id' ]) ? $this->params[ 'groupbuy_id' ] : '',//团购id - 'num' => isset($this->params[ 'num' ]) ? $this->params[ 'num' ] : 1,//商品数量(买几套) - 'sku_id' => isset($this->params[ 'sku_id' ]) ? $this->params[ 'sku_id' ] : 0,//sku_id - 'member_id' => $this->member_id, - 'site_id' => $this->site_id,//站点id - 'is_balance' => isset($this->params[ 'is_balance' ]) ? $this->params[ 'is_balance' ] : 0,//是否使用余额 - 'order_from' => $this->params[ 'app_type' ], - 'order_from_name' => $this->params[ 'app_type_name' ], - - 'latitude' => $this->params[ "latitude" ] ?? '', - 'longitude' => $this->params[ "longitude" ] ?? '', - 'default_store_id' => $this->params[ "default_store_id" ] ?? 0, - - ]; - if (empty($data[ 'sku_id' ]) || empty($data[ 'groupbuy_id' ])) { - return $this->response($this->error('', '缺少必填参数商品数据')); - } - $res = $order_create->orderPayment($data); - return $this->response($this->success($res)); - } - -} \ No newline at end of file diff --git a/addon/activity/component/controller/Groupbuy.php b/addon/activity/component/controller/Groupbuy.php deleted file mode 100644 index a7282d4..0000000 --- a/addon/activity/component/controller/Groupbuy.php +++ /dev/null @@ -1,21 +0,0 @@ -fetch("groupbuy/design.html"); - } -} \ No newline at end of file diff --git a/addon/activity/component/view/groupbuy/css/design.css b/addon/activity/component/view/groupbuy/css/design.css deleted file mode 100644 index 44f8acb..0000000 --- a/addon/activity/component/view/groupbuy/css/design.css +++ /dev/null @@ -1,29 +0,0 @@ -@CHARSET "UTF-8"; - -/* 样式:单列 */ -.component-groupbuy .groupbuy-list .row1-of1{} -.component-groupbuy .groupbuy-list .row1-of1 .item{display: flex;margin-bottom: 10px;padding: 8px;} -.component-groupbuy .groupbuy-list .row1-of1 .item:last-child{margin-bottom: 0;} -.component-groupbuy .groupbuy-list .row1-of1 .item .img-wrap {width: 100px;height: 100px;} -.component-groupbuy .groupbuy-list .row1-of1 .item .img-wrap > img{width: 100%;} -.component-groupbuy .groupbuy-list .row1-of1 .item .img-wrap .bg{display: none;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content{flex:1;margin-left: 10px;position: relative;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content .goods-name{margin-top: 3px;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content .discount-price{font-weight: bold;font-size: 0;position: absolute;bottom: 3px;left: 0;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content .discount-price .unit{font-size: 12px;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content .discount-price .price{font-size: 16px;} -.component-groupbuy .groupbuy-list .row1-of1 .item .content button{position: absolute;bottom: 3px;right: 10px;padding: 0 8px;height: 26px;font-size: 12px;line-height: 26px;} - -/* 样式:横向滑动 */ -.component-groupbuy .groupbuy-list .horizontal-slide{display: flex;margin: 10px;overflow: hidden;} -.component-groupbuy .groupbuy-list .horizontal-slide .item {width: 97px;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .img-wrap {width: 97px;height: 97px;overflow: hidden;position: relative;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .img-wrap > img{width: calc(100% + 1px);} -.component-groupbuy .groupbuy-list .horizontal-slide .item .img-wrap .bg {position: absolute;width: 100%;height: 30px;bottom: 0;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .img-wrap .bg img {width: 100%;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .img-wrap .num {width: 90px;position: absolute;bottom: 5px;padding-left: 10px;font-size: 12px;line-height: 1;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .content {padding: 5px 10px;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .content .discount-price{margin-top: 5px;font-weight: bold;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .content .discount-price .unit{font-size: 12px; height: 16px;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .content .discount-price .price{font-size: 16px;} -.component-groupbuy .groupbuy-list .horizontal-slide .item .content .original-price {font-size: 12px;line-height: 1;margin-top: 5px;text-decoration: line-through;} \ No newline at end of file diff --git a/addon/activity/component/view/groupbuy/design.html b/addon/activity/component/view/groupbuy/design.html deleted file mode 100644 index 7ed6b32..0000000 --- a/addon/activity/component/view/groupbuy/design.html +++ /dev/null @@ -1,290 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/addon/activity/component/view/groupbuy/img/bg.png b/addon/activity/component/view/groupbuy/img/bg.png deleted file mode 100644 index 53d2d79..0000000 Binary files a/addon/activity/component/view/groupbuy/img/bg.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/blue.png b/addon/activity/component/view/groupbuy/img/blue.png deleted file mode 100644 index 3404173..0000000 Binary files a/addon/activity/component/view/groupbuy/img/blue.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/goods.png b/addon/activity/component/view/groupbuy/img/goods.png deleted file mode 100644 index 5f1c884..0000000 Binary files a/addon/activity/component/view/groupbuy/img/goods.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/goods_1.png b/addon/activity/component/view/groupbuy/img/goods_1.png deleted file mode 100644 index 37e6624..0000000 Binary files a/addon/activity/component/view/groupbuy/img/goods_1.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/icon/groupbuy.png b/addon/activity/component/view/groupbuy/img/icon/groupbuy.png deleted file mode 100644 index 52fe098..0000000 Binary files a/addon/activity/component/view/groupbuy/img/icon/groupbuy.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/icon/groupbuy_selected.png b/addon/activity/component/view/groupbuy/img/icon/groupbuy_selected.png deleted file mode 100644 index 9bbd7dd..0000000 Binary files a/addon/activity/component/view/groupbuy/img/icon/groupbuy_selected.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/manual.png b/addon/activity/component/view/groupbuy/img/manual.png deleted file mode 100644 index d22f765..0000000 Binary files a/addon/activity/component/view/groupbuy/img/manual.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/manual_1.png b/addon/activity/component/view/groupbuy/img/manual_1.png deleted file mode 100644 index 0d283ba..0000000 Binary files a/addon/activity/component/view/groupbuy/img/manual_1.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/red.png b/addon/activity/component/view/groupbuy/img/red.png deleted file mode 100644 index 76bd1ec..0000000 Binary files a/addon/activity/component/view/groupbuy/img/red.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style1.png b/addon/activity/component/view/groupbuy/img/style1.png deleted file mode 100644 index 2464149..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style1.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style2 - ╕▒▒╛.png b/addon/activity/component/view/groupbuy/img/style2 - ╕▒▒╛.png deleted file mode 100644 index e69de29..0000000 diff --git a/addon/activity/component/view/groupbuy/img/style2 - .png b/addon/activity/component/view/groupbuy/img/style2 - .png deleted file mode 100644 index af4ac50..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style2 - .png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style2.png b/addon/activity/component/view/groupbuy/img/style2.png deleted file mode 100644 index 13924e8..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style2.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style2_title.png b/addon/activity/component/view/groupbuy/img/style2_title.png deleted file mode 100644 index 8deb43e..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style2_title.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style3 - ╕▒▒╛.png b/addon/activity/component/view/groupbuy/img/style3 - ╕▒▒╛.png deleted file mode 100644 index e69de29..0000000 diff --git a/addon/activity/component/view/groupbuy/img/style3 - .png b/addon/activity/component/view/groupbuy/img/style3 - .png deleted file mode 100644 index b3f754e..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style3 - .png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style3.png b/addon/activity/component/view/groupbuy/img/style3.png deleted file mode 100644 index 3f6aad5..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style3.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/style3_title.png b/addon/activity/component/view/groupbuy/img/style3_title.png deleted file mode 100644 index 8c82f51..0000000 Binary files a/addon/activity/component/view/groupbuy/img/style3_title.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/violet.png b/addon/activity/component/view/groupbuy/img/violet.png deleted file mode 100644 index 195bcdf..0000000 Binary files a/addon/activity/component/view/groupbuy/img/violet.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/img/yellow.png b/addon/activity/component/view/groupbuy/img/yellow.png deleted file mode 100644 index 530d028..0000000 Binary files a/addon/activity/component/view/groupbuy/img/yellow.png and /dev/null differ diff --git a/addon/activity/component/view/groupbuy/js/design.js b/addon/activity/component/view/groupbuy/js/design.js deleted file mode 100644 index a3fffb4..0000000 --- a/addon/activity/component/view/groupbuy/js/design.js +++ /dev/null @@ -1,131 +0,0 @@ -var groupbuyListHtml = '
'; - -Vue.component("groupbuy-list-sources", { - template: groupbuyListHtml, - data: function () { - return { - data: this.$parent.data, - goodsSources: { - initial: { - text: "默认", - icon: "iconmofang" - }, - diy: { - text: "手动选择", - icon: "iconshoudongxuanze" - }, - }, - templateList: { - "row1-of1": { - text: "单列", - icon: "iconiPhone86", - styleList: [ - { - text: "样式1", - value: "style-1", - cartSupport: true, // 是否支持按钮 - saleSupport: false, // 是否支持商品销量 - lineSupport: false, // 是否支持划线价 - }, - ], - }, - "horizontal-slide": { - text: "横向滑动", - icon: "iconshangpinliebiaohengxianghuadong", - styleList: [ - { - text: "样式1", - value: "style-1", - cartSupport: false, // 是否支持按钮 - saleSupport: true, // 是否支持商品销量 - lineSupport: true, // 是否支持划线价 - }, - ], - }, - }, - ornamentList: [ - { - type: 'default', - text: '默认', - }, - { - type: 'shadow', - text: '投影', - }, - { - type: 'stroke', - text: '描边', - }, - ], - nameLineModeList: [ - { - text: "单行", - value: "single" - }, - { - text: "多行", - value: "multiple" - } - ] - } - }, - created: function () { - if (!this.$parent.data.verify) this.$parent.data.verify = []; - this.$parent.data.verify.push(this.verify);//加载验证方法 - - this.$parent.data.ignore = ['textColor']; //加载忽略内容 -- 其他设置中的属性设置 - this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载 - - var previewList = {}; - for (var i = 1; i < 4; i++) { - previewList["goods_id_" + ns.gen_non_duplicate(i)] = { - goods_name: "团购商品", - discount_price: (Math.random() * 100 * i + 10).toFixed(2), // 随机价格 - line_price: (Math.random() * 100 * i + 100 + 10).toFixed(2), // 随机价格 - sale_num: Math.floor((Math.random() * 100 * i + 10 + 10)) - }; - } - - // 组件所需的临时数据 - this.$parent.data.tempData = { - goodsSources: this.goodsSources, - templateList: this.templateList, - ornamentList: this.ornamentList, - nameLineModeList: this.nameLineModeList, - previewList: previewList, - methods: { - addGoods: this.addGoods, - selectTemplate: this.selectTemplate - } - }; - }, - methods: { - verify: function (index) { - var res = {code: true, message: ""}; - if (vue.data[index].sources === 'diy' && vue.data[index].goodsId.length === 0) { - res.code = false; - res.message = "请选择商品"; - } - return res; - }, - addGoods: function () { - var self = this; - goodsSelect(function (res) { - self.$parent.data.goodsId = res; - }, self.$parent.data.goodsId, {mode: "spu", promotion: "groupbuy", disabled: 0, post: ns.appModule}); - }, - selectTemplate(template, item) { - if (template) { - this.$parent.data.template = template; - item = this.templateList[template].styleList[0]; - } - this.$parent.data.style = item.value; - this.$parent.data.btnStyle.support = item.cartSupport; - this.$parent.data.btnStyle.control = item.cartSupport; - this.$parent.data.saleStyle.support = item.saleSupport; - this.$parent.data.saleStyle.control = item.saleSupport; - this.$parent.data.priceStyle.lineSupport = item.lineSupport; - this.$parent.data.priceStyle.lineControl = item.lineSupport; - }, - } -}); \ No newline at end of file diff --git a/addon/activity/config/diy_view.php b/addon/activity/config/diy_view.php deleted file mode 100644 index e9de4a4..0000000 --- a/addon/activity/config/diy_view.php +++ /dev/null @@ -1,75 +0,0 @@ - '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ] - 'template' => [], - - // 后台自定义组件——装修 - 'util' => [ - // [ - // 'name' => 'Activity', - // 'title' => '拓客活动', - // 'type' => 'PROMOTION', - // 'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"horizontal-slide","goodsMarginType":"default","goodsMarginNum":10,"btnStyle":{"text":"立即团购","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":false,"support":false,"bgColorStart":"#FF7B1D","bgColorEnd":"#FF1544"},"imgAroundRadius":5,"slideMode":"scroll","theme":"default","goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false},"priceStyle":{"mainColor":"#FF1745","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"saleStyle":{"color":"#FFFFFF","control":true,"support":true},"titleStyle":{"isShow":true,"leftStyle":"text","leftImg":"","style":"style-1","styleName":"风格1","leftText":"限时秒杀","fontSize":16,"fontWeight":true,"textColor":"#303133","bgColorStart":"#FFFFFF","bgColorEnd":"#FFFFFF","more":"查看更多","moreColor":"#999999","moreFontSize":12}}', - // 'sort' => '30005', - // 'support_diy_view' => '', - // 'max_count' => 0, - // 'icon' => 'iconfont icontuangou1', - // ] - ], - - // 自定义页面路径 - 'link' => [ - // [ - // 'name' => 'Activity', - // 'title' => '拓客活动', - // 'parent' => 'MARKETING_LINK', - // 'wap_url' => '', - // 'web_url' => '', - // 'sort' => 0, - // 'child_list' => [ - // [ - // 'name' => 'ACTIVITY_PREFECTURE', - // 'title' => '活动专区', - // 'wap_url' => '/pages_promotion/activity/list', - // 'web_url' => '', - // 'sort' => 0 - // ] - // ] - // ], - // [ - // 'name' => 'ACTIVITY_GOODS', - // 'title' => '活动商品', - // 'parent' => 'COMMODITY', - // 'wap_url' => '', - // 'web_url' => '', - // 'child_list' => [] - // ] - ], - - // 自定义图标库 - 'icon_library' => [], - - // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件 - 'component' => [], - - // uni-app 页面,多个逗号隔开 - 'pages' => [], - - // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述' - 'info' => [], - - // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】 - 'theme' => [], - - // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ] - 'data' => [] -]; \ No newline at end of file diff --git a/addon/activity/config/event.php b/addon/activity/config/event.php deleted file mode 100644 index 6c076fe..0000000 --- a/addon/activity/config/event.php +++ /dev/null @@ -1,26 +0,0 @@ - [ - - ], - 'listen' => [ - //开启拓客 - 'OpenActivity' => [ - 'addon\activity\event\OpenActivity', - ], - //关闭拓客 - 'CloseActivity' => [ - 'addon\activity\event\CloseActivity', - ], - - //展示活动 - 'ShowPromotion' => [ - 'addon\activity\event\ShowPromotion', - ], - - ], - - 'subscribe' => [ - ], -]; diff --git a/addon/activity/config/info.php b/addon/activity/config/info.php deleted file mode 100644 index 0798775..0000000 --- a/addon/activity/config/info.php +++ /dev/null @@ -1,20 +0,0 @@ - 'activity', - 'title' => '拓客活动', - 'description' => '拓客管理活动', - 'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件 - 'status' => 1, - 'author' => '', - 'version' => '1.0.0', - 'version_no' => '520230316001', - 'content' => '', -]; \ No newline at end of file diff --git a/addon/activity/config/menu_shop.php b/addon/activity/config/menu_shop.php deleted file mode 100644 index 48a4de5..0000000 --- a/addon/activity/config/menu_shop.php +++ /dev/null @@ -1,57 +0,0 @@ - 'PROMOTION_ACTIVITY', - 'title' => '拓客活动', - 'url' => 'activity://shop/activity/lists', - 'parent' => 'PROMOTION_CENTER', - 'is_show' => 1, - 'sort' => 100, - 'child_list' => [ - [ - 'name' => 'PROMOTION_ACTIVITY_LIST', - 'title' => '活动列表', - 'url' => 'activity://shop/activity/lists', - 'parent' => 'PROMOTION_ACTIVITY', - 'is_show' => 1, - 'child_list' => [ - [ - 'name' => 'PROMOTION_ACTIVITY_ADD', - 'title' => '添加活动', - 'url' => 'activity://shop/activity/add', - 'sort' => 1, - 'is_show' => 0 - ], - [ - 'name' => 'PROMOTION_ACTIVITY_EDIT', - 'title' => '编辑活动', - 'url' => 'activity://shop/activity/edit', - 'sort' => 1, - 'is_show' => 0 - ], - [ - 'name' => 'PROMOTION_ACTIVITY_DELETE', - 'title' => '删除活动', - 'url' => 'activity://shop/activity/delete', - 'sort' => 1, - 'is_show' => 0 - ], - [ - 'name' => 'PROMOTION_ACTIVITY_FINISH', - 'title' => '结束活动', - 'url' => 'activity://shop/activity/finish', - 'sort' => 1, - 'is_show' => 0 - ] - - ] - - ], - ] - ], - -]; \ No newline at end of file diff --git a/addon/activity/data/install.sql b/addon/activity/data/install.sql deleted file mode 100644 index 22c382d..0000000 --- a/addon/activity/data/install.sql +++ /dev/null @@ -1 +0,0 @@ -SET NAMES 'utf8'; \ No newline at end of file diff --git a/addon/activity/data/uninstall.sql b/addon/activity/data/uninstall.sql deleted file mode 100644 index 0b4cf1b..0000000 --- a/addon/activity/data/uninstall.sql +++ /dev/null @@ -1 +0,0 @@ -SET NAMES 'utf8'; diff --git a/addon/activity/event/CloseActivity.php b/addon/activity/event/CloseActivity.php deleted file mode 100644 index 873e281..0000000 --- a/addon/activity/event/CloseActivity.php +++ /dev/null @@ -1,28 +0,0 @@ -cronCloseActivity($params['relate_id']); - return $res; - } -} \ No newline at end of file diff --git a/addon/activity/event/Install.php b/addon/activity/event/Install.php deleted file mode 100644 index 43cea76..0000000 --- a/addon/activity/event/Install.php +++ /dev/null @@ -1,25 +0,0 @@ -cronOpenActivity($params['relate_id']); - return $res; - } -} \ No newline at end of file diff --git a/addon/activity/event/ShowPromotion.php b/addon/activity/event/ShowPromotion.php deleted file mode 100644 index 33de4bd..0000000 --- a/addon/activity/event/ShowPromotion.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - [ - //插件名称 - 'name' => 'activity', - //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具) - 'show_type' => 'shop', - //展示主题 - 'title' => '拓客活动', - //展示介绍 - 'description' => '供应链拓客活动,平台拓客,无需备货', - //展示图标 - 'icon' => 'addon/activity/icon.png', - //跳转链接 - 'url' => 'activity://shop/activity/lists', - ] - ] - ]; - return $data; - } -} diff --git a/addon/activity/event/UnInstall.php b/addon/activity/event/UnInstall.php deleted file mode 100644 index 403346c..0000000 --- a/addon/activity/event/UnInstall.php +++ /dev/null @@ -1,25 +0,0 @@ - $time){ - $data['status'] = 1; - }else if($data['start_time'] < $time){ - $data['status'] = 0; - }else if($data['end_time'] > time()){ - $data['status'] = 2; - } - model('promotion_activity')->startTrans(); - try{ - $activity_id = model('promotion_activity')->add($data); - if($activity_id){ - $cron = new Cron(); - if($data['status'] === 0){ - $cron->addCron(1, 0, "拓客活动开启", "OpenActivity", $data[ 'start_time' ], $activity_id); - $cron->addCron(1, 0, "拓客活动关闭", "CloseActivity", $data[ 'end_time' ], $activity_id); - }else{ - $cron->addCron(1, 0, "拓客活动关闭", "CloseActivity", $data[ 'end_time' ], $activity_id); - } - } - - model('promotion_activity')->commit(); - return $this->success(); - }catch(\Exception $e){ - model('promotion_activity')->rollback(); - return $this->error(); - } - } - /** - * Common: 添加拓客活动 - * Author: ldy - * Time: 2024/08/22 15:24 - * Interface addActivity - * @package addon\activity\model - */ - public function editActivity($activity_id,$data,$site_id){ - $time = time(); - if($data['start_time'] < $time && $data['end_time'] > $time){ - $data['status'] = 1; - }else if($data['start_time'] < $time){ - $data['status'] = 0; - }else if($data['end_time'] > time()){ - $data['status'] = 2; - } - model('promotion_activity')->startTrans(); - try{ - $res = model('promotion_activity')->update($data,[ [ 'activity_id', '=', $activity_id ], [ 'site_id', '=', $site_id ] ]); - if($activity_id){ - $cron = new Cron(); - if($data['status'] === 0){ - $cron->deleteCron([ [ 'event', '=', 'OpenActivity' ], [ 'relate_id', '=', $activity_id ] ]); - $cron->deleteCron([ [ 'event', '=', 'CloseActivity' ], [ 'relate_id', '=', $activity_id ] ]); - - $cron->addCron(1, 0, "拓客活动开启", "OpenActivity", $data[ 'start_time' ], $activity_id); - $cron->addCron(1, 0, "拓客活动关闭", "CloseActivity", $data[ 'end_time' ], $activity_id); - }else{ - $cron->deleteCron([ [ 'event', '=', 'OpenActivity' ], [ 'relate_id', '=', $activity_id ] ]); - $cron->deleteCron([ [ 'event', '=', 'CloseActivity' ], [ 'relate_id', '=', $activity_id ] ]); - - $cron->addCron(1, 0, "拓客活动关闭", "CloseActivity", $data[ 'end_time' ], $activity_id); - } - } - - model('promotion_activity')->commit(); - return $this->success($res); - }catch(\Exception $e){ - model('promotion_activity')->rollback(); - return $this->error(); - } - } - /** - * Common: 关闭拓客活动 - * Author: ldy - * Time: 2024/08/22 14:03 - * Interface cronCloseActivity - * @package addon\activity\model - */ - public function getActivityPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '') - { - - $field = '*'; - $list = model('promotion_activity')->pageList($condition, $field, $order, $page, $page_size); - if($list && count($list['list'])){ - foreach($list['list'] as $key => &$value){ - $value['goods'] = self::getActivityGoods(json_decode($value['goods_ids'])); - $value['form_title'] = $value['form_id'] > 0 ? model('form')->getValue(['id' => $value['form_id']],'form_name') : '暂无'; - $value['poster_title'] = $value['template_id'] > 0 ? model('poster_template')->getValue(['template_id' => $value['template_id']],'poster_name') : '暂无'; - } - } - return $this->success($list); - } - - public function getActivityInfo($condition = [], $field = '*'){ - $info = model("promotion_activity")->getInfo($condition, $field); - if($info){ - $goods_ids = json_decode($info['goods_ids'],true); - $info['goods_ids'] = $goods_ids; - $info['activity_image'] = implode(',',json_decode($info['activity_image'],true)); - $goods = self::getActivityGoods($goods_ids); - $info['goods'] = $goods; - $info['goods_num'] = count($goods); - $divide_money_ids = json_decode($info['divide_money_ids'],true);//分账账号 - $info['divide_money_ids'] = $divide_money_ids; - $info['divide_ids'] = implode(',',$divide_money_ids); - } - return $this->success($info); - } - - /** - * 删除拓客活动 - * @param $groupbuy_id - * @param $site_id - * @return array|\multitype - */ - public function deleteActivity($activity_id, $site_id) - { - //团购信息 - $info = model('promotion_activity')->getInfo([ [ 'activity_id', '=', $activity_id ], [ 'site_id', '=', $site_id ] ], 'activity_id,status'); - if ($info) { - if ($info['status'] == 1) { - $res = model('promotion_activity')->delete([ [ 'activity_id', '=', $activity_id ] ]); - if ($res) { - $cron = new Cron(); - $cron->deleteCron([ [ 'event', '=', 'OpenActivity' ], [ 'relate_id', '=', $activity_id ] ]); - $cron->deleteCron([ [ 'event', '=', 'CloseActivity' ], [ 'relate_id', '=', $activity_id ] ]); - } - return $this->success($res); - } else { - return $this->error('', '拓客活动进行中'); - } - } else { - return $this->error('', '拓客活动不存在'); - } - } - - public function urlQrcode($page, $qrcode_param, $promotion_type, $site_id) - { - $params = [ - 'site_id' => $site_id, - 'data' => $qrcode_param, - 'page' => $page, - 'promotion_type' => $promotion_type, - 'h5_path' => $page . '?id=' . $qrcode_param[ 'id' ], - 'qrcode_path' => 'upload/qrcode/activity', - 'qrcode_name' => [ - 'h5_name' => 'activity_qrcode_' . $promotion_type . '_h5_' . $qrcode_param[ 'id' ] . '_' . $site_id, - 'weapp_name' => 'activity_qrcode_' . $promotion_type . '_weapp_' . $qrcode_param[ 'id' ] . '_' . $site_id - ] - ]; - - $solitaire = event('ExtensionInformation', $params); - return $this->success($solitaire[ 0 ]); - } - - /** - * Common: 关闭拓客活动 - * Author: ldy - * Time: 2024/08/23 11:08 - * Interface cronCloseActivity - * @package addon\activity\model - */ - public function cronCloseActivity($activity_id){ - return model('promotion_activity')->update(['status' => 2],[ [ 'activity_id', '=', $activity_id ]]); - } - /** - * Common: 开启拓客活动 - * Author: ldy - * Time: 2024/08/23 11:02 - * Interface cronOpenActivity - * @package addon\activity\model - */ - public function cronOpenActivity($activity_id){ - return model('promotion_activity')->update(['status' => 1],[ [ 'activity_id', '=', $activity_id ]]); - } - - - protected function getActivityGoods($goods_ids){ - $model = new Goods(); - $goods = $model->getGoodsSelect([ [ 'goods_id', 'in', $goods_ids ] ], 'goods_name,goods_image,price,goods_stock,goods_service_ids'); - return $goods['data']; - } - - - /** - * 获取活动商品详情 - * @param $condition - * @param string $field - * @return array - */ - public function getActivityGoodsDetail($condition, $field = '') - { - if (empty($field)) { - $field = 'sku.goods_id,sku.sku_id,sku.sku_name,sku.sku_spec_format,sku.price,sku.promotion_type,sku.stock,sku.click_num,(g.sale_num + g.virtual_sale) as sale_num,sku.collect_num,sku.sku_image,sku.sku_images,sku.site_id,sku.goods_content,sku.goods_state,sku.is_virtual,sku.is_free_shipping,sku.goods_spec_format,sku.goods_attr_format,sku.introduction,sku.support_trade_type,sku.unit,sku.video_url,sku.evaluate,sku.goods_service_ids,ptg.id,ptg.topic_id,ptg.start_time,ptg.end_time,ptg.topic_price,pt.topic_name,g.goods_image,g.goods_stock,g.goods_name,sku.qr_id,sku.market_price,g.stock_show,g.sale_show,g.market_price_show,g.barrage_show,g.label_name,pt.remark'; - } - $alias = 'ptg'; - $join = [ - [ 'goods_sku sku', 'ptg.sku_id = sku.sku_id', 'inner' ], - [ 'goods g', 'g.goods_id = sku.goods_id', 'inner' ], -// [ 'promotion_topic pt', 'pt.topic_id = ptg.topic_id', 'inner' ], - ]; - $info = model('promotion_activity')->getInfo($condition, $field, $alias, $join); - if (!empty($info)) { - if (isset($info[ 'sale_num' ])) { - $info[ 'sale_num' ] = numberFormat($info[ 'sale_num' ]); - } - if (isset($info[ 'stock' ])) { - $info[ 'stock' ] = numberFormat($info[ 'stock' ]); - } - if (isset($info[ 'goods_stock' ])) { - $info[ 'goods_stock' ] = numberFormat($info[ 'goods_stock' ]); - } - } - return $this->success($info); - } -} diff --git a/addon/activity/shop/controller/Activity.php b/addon/activity/shop/controller/Activity.php deleted file mode 100644 index ad02eec..0000000 --- a/addon/activity/shop/controller/Activity.php +++ /dev/null @@ -1,216 +0,0 @@ -isAjax()) { - - $condition = [ - [ 'site_id', '=', $this->site_id ], - [ 'is_del', '=', 1 ] - ]; - - $status = input('status', '');//团购状态 - if ($status !== '') { - $condition[] = [ 'status', '=', $status ]; - } - - $start_time = input('start_time', ''); - $end_time = input('end_time', ''); - - if ($start_time && !$end_time) { - $condition[] = [ 'end_time', '>=', date_to_time($start_time) ]; - } elseif (!$start_time && $end_time) { - $condition[] = [ 'start_time', '<=', date_to_time($end_time) ]; - } elseif ($start_time && $end_time) { - $start_timestamp = date_to_time($start_time); - $end_timestamp = date_to_time($end_time); - $sql = "start_time between {$start_timestamp} and {$end_timestamp}"; - $sql .= " or end_time between {$start_timestamp} and {$end_timestamp}"; - $sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})"; - $condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ]; - } - - //排序 - $order = input('order', 'create_time'); - $sort = input('sort', 'desc'); - if ($order == 'create_time') { - $order_by = $order . ' ' . $sort; - } else { - $order_by = $order . ' ' . $sort . ',create_time desc'; - } - - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $list = $model->getActivityPageList($condition, $page, $page_size, $order_by); - return $list; - } else { - return $this->fetch("activity/lists"); - } - } - - /** - * 添加活动 - */ - public function add() - { - if (request()->isAjax()) { - //获取商品信息 - $data = [ - 'site_id' => $this->site_id, - 'activity_image' => json_encode(input('activity_image','')), - 'activity_price' => input('activity_price',0), - 'remark' => input('remark',''), - 'content' => input('content',''), - 'audio_url' => input('audio_url',''), - 'goods_ids' => json_encode(input('goods_ids','')), - 'start_time' => strtotime(input('start_time', '')), - 'end_time' => strtotime(input('end_time', '')), - 'template_id' => input('template_id',0), - 'form_id' => input('form_id',0), - 'payee_name' => input('payee_name',''), - 'payee_account' => input('payee_account',''), - 'divide_money_ids' => json_encode(input('divide_money_ids','')), - 'virtual_sale' => input('virtual_sale',0), - 'buy_agreement' => input('buy_agreement',''), - 'is_recycle_integral' => input('is_recycle_integral',0), - 'create_time' => time(), - 'status' => 0 - ]; - $model = new ActivityModel(); - return $model->addActivity($data); - } else { - //获取海报 - $poster_template_model = new PosterTemplateModel(); - $poster_list = $poster_template_model->getPosterTemplateList([['site_id', '=', $this->site_id], ['template_status', '=', 1]], 'template_id,poster_name,site_id'); - $this->assign('poster_list', $poster_list['data']); - // $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id)); - - $form_is_exit = addon_is_exit('form', $this->site_id); - if ($form_is_exit) { - $form_list = (new Form())->getFormList([['site_id', '=', $this->site_id], ['form_type', '=', 'custom'], ['is_use', '=', 1]], 'id desc', 'id, form_name')['data']; - $this->assign('form_list', $form_list); - } - $this->assign('form_is_exit', $form_is_exit); - - $divide_money_is_exit = addon_is_exit('dividemoney', $this->site_id); - $this->assign('divide_money_is_exit', $divide_money_is_exit); - return $this->fetch("activity/add"); - } - } - - /** - * 编辑活动 - */ - public function edit() - { - $activity_id = input('activity_id', ''); - $model = new ActivityModel(); - - if (request()->isAjax()) { - //获取商品信息 - $data = [ - 'site_id' => $this->site_id, - 'activity_image' => json_encode(input('activity_image','')), - 'activity_price' => input('activity_price',0), - 'remark' => input('remark',''), - 'content' => input('content',''), - 'audio_url' => input('audio_url',''), - 'goods_ids' => json_encode(input('goods_ids','')), - 'start_time' => strtotime(input('start_time', '')), - 'end_time' => strtotime(input('end_time', '')), - 'template_id' => input('template_id',0), - 'form_id' => input('form_id',0), - 'payee_name' => input('payee_name',''), - 'payee_account' => input('payee_account',''), - 'divide_money_ids' => json_encode(input('divide_money_ids','')), - 'virtual_sale' => input('virtual_sale',0), - 'buy_agreement' => input('buy_agreement',''), - 'is_recycle_integral' => input('is_recycle_integral',0), - 'update_time' => time(), - ]; - return $model->editActivity($activity_id, $data, $this->site_id); - } else { - //获取海报 - $poster_template_model = new PosterTemplateModel(); - $poster_list = $poster_template_model->getPosterTemplateList([['site_id', '=', $this->site_id], ['template_status', '=', 1]], 'template_id,poster_name,site_id'); - $this->assign('poster_list', $poster_list['data']); - - $form_is_exit = addon_is_exit('form', $this->site_id); - if ($form_is_exit) { - $form_list = (new Form())->getFormList([['site_id', '=', $this->site_id], ['form_type', '=', 'goods'], ['is_use', '=', 1]], 'id desc', 'id, form_name')['data']; - $this->assign('form_list', $form_list); - }else{ - $this->assign('form_list', []); - } - $this->assign('form_is_exit', $form_is_exit); - - $divide_money_is_exit = addon_is_exit('dividemoney', $this->site_id); - $this->assign('divide_money_is_exit', $divide_money_is_exit); - - //获取团购信息 - $condition = [ - [ 'activity_id', '=', $activity_id ], - [ 'site_id', '=', $this->site_id ], - [ 'is_del', '=', 1 ] - ]; - $info = $model->getActivityInfo($condition)[ 'data' ]; - if (empty($info)) $this->error('未获取到活动数据', addon_url('activity://shop/activity/lists')); - $divide_list = []; - if(count($info['divide_money_ids']) > 0 && $divide_money_is_exit){ - $divide_list = (new DividemoneyAccount())->getDivideList([['site_id','=', $this->site_id],['id', 'in', $info['divide_money_ids']]],'id,account,realname'); - } - $this->assign('divide_list', $divide_list); - $this->assign('info', $info); - return $this->fetch("activity/edit"); - } - } - - /* - * 删除团购活动 - */ - public function delete() - { - $activity_id = input('activity_id', ''); - $groupbuy_model = new ActivityModel(); - return $groupbuy_model->deleteActivity($activity_id, $this->site_id); - } - - /** - * 团购推广 - */ - public function activityUrl() - { - $activity_id = input('activity_id', ''); - $model = new ActivityModel(); - $res = $model->urlQrcode('/pages_promotion/activity/detail', [ 'id' => $activity_id ], 'activity', $this->site_id); - return $res; - } -} diff --git a/addon/activity/shop/view/activity/add.html b/addon/activity/shop/view/activity/add.html deleted file mode 100644 index db9e336..0000000 --- a/addon/activity/shop/view/activity/add.html +++ /dev/null @@ -1,644 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
- -
-
- - -
- - -
- - -
-
-
-
- -
-
-
-
- - -
- -
- -
-
- - -
- -
- -
-
- - - - - - - - - - - - - - - -
- -
- -
-
- - {if $form_is_exit} -
- -
- -
-
- {/if} -
- -
-
- -
-
-
开启活动收款功能,可单独设置活动收款账号,不设置则使用店铺默认收款账号。
-
-
- -
- -
-
-
- -
- -
-
独立收款,目前仅支持畅捷支付收款
-
- {if $divide_money_is_exit} -
- -
-
-
- -
- - - - - - - - - - - - - - - - -
账号ID企业名称账号操作
-
-
-
-
-
- {/if} - -
- -
-
- - 已选商品(0 -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - -
-
- -
- - -
- - -
-{/block} -{block name="script"} - - - - - - - - - - - - -{/block} diff --git a/addon/activity/shop/view/activity/edit.html b/addon/activity/shop/view/activity/edit.html deleted file mode 100644 index d9af70a..0000000 --- a/addon/activity/shop/view/activity/edit.html +++ /dev/null @@ -1,643 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
- - -
- -
-
- - -
- - -
- - - -
-
-
-
- -
-
-
-
- -
- -
- -
-
- - -
- -
- -
-
- - - - - - - - - - - - - - -
- -
- -
-
- - {if $form_is_exit} -
- -
- -
-
- {/if} - -
- -
- -
-
-
- -
- -
-
- {if $divide_money_is_exit} -
- -
-
-
- -
- - - - - - - - - - - - - - - - - {if isset($divide_list) && !empty($divide_list)} - {foreach $divide_list as $k => $vo} - - - - - - - {/foreach} - - {/if} - -
账号ID企业名称账号操作
{$vo.id}{$vo.realname}{$vo.account}删除
-
-
-
-
-
- {/if} - -
- -
-
- - 已选商品({$info.goods_num} -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- - -
-
- - -
- - -
- - - - - - -
-{/block} -{block name="script"} - - - - - - - - - - - - -{/block} diff --git a/addon/activity/shop/view/activity/lists.html b/addon/activity/shop/view/activity/lists.html deleted file mode 100644 index 2e93f14..0000000 --- a/addon/activity/shop/view/activity/lists.html +++ /dev/null @@ -1,444 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} - -
- -
- - -
-
-
-
- - - - - - -
- -
- - -
-
-
-
- - -
-
-
- -
- - -
-
-
-
- -
- -
- -
-
-
- - - - - - - - - - - - - - -{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/activity/shop/view/public/img/zone_preview.png b/addon/activity/shop/view/public/img/zone_preview.png deleted file mode 100644 index 5191431..0000000 Binary files a/addon/activity/shop/view/public/img/zone_preview.png and /dev/null differ diff --git a/addon/ali1688/api/controller/Notify.php b/addon/ali1688/api/controller/Notify.php deleted file mode 100644 index 2930f50..0000000 --- a/addon/ali1688/api/controller/Notify.php +++ /dev/null @@ -1,22 +0,0 @@ -getMessage(); - } - } -} \ No newline at end of file diff --git a/addon/ali1688/config/diy_view.php b/addon/ali1688/config/diy_view.php deleted file mode 100644 index bb54e83..0000000 --- a/addon/ali1688/config/diy_view.php +++ /dev/null @@ -1,31 +0,0 @@ - '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ] - 'template' => [], - // 后台自定义组件——装修 - 'util' => [], - // 自定义页面路径 - 'link' => [], - // 自定义图标库 - 'icon_library' => [], - // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件 - 'component' => [], - // uni-app 页面,多个逗号隔开 - 'pages' => [], - // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述' - 'info' => [], - // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】 - 'theme' => [], - // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ] - 'data' => [] -]; \ No newline at end of file diff --git a/addon/ali1688/config/event.php b/addon/ali1688/config/event.php deleted file mode 100644 index 6936307..0000000 --- a/addon/ali1688/config/event.php +++ /dev/null @@ -1,35 +0,0 @@ - [], - 'listen' => [ - //展示活动 - 'ShowPromotion' => [ - 'addon\ali1688\event\ShowPromotion', - ], - // 支付成功 - 'OrderPay' => [ - 'addon\ali1688\event\OrderPay', - ], - // 自动下单 - 'CronAutoAliOrderBuy' => [ - 'addon\ali1688\event\Ali1688OrderBuy', - ], - 'OrderRefundFinish' => [ // 退款成功 -// 'addon\ali1688\event\Ali1688OrderRefund', - ], - 'AutoAddGoods' => [ //自动添加商品 - 'addon\ali1688\event\AutoAddGoods', - ], - 'DeleteRecycleGoods' => [ //删除商品 - 'addon\ali1688\event\DeleteRecycleGoods', - ], - 'Notify1688Change' => [ //1688状态通知 - 'addon\ali1688\event\Notify1688Change' - ], - 'OrderCreate' => [ // 订单创建 - 'addon\ali1688\event\OrderCreate', - ], - ], - 'subscribe' => [], -]; diff --git a/addon/ali1688/config/info.php b/addon/ali1688/config/info.php deleted file mode 100644 index ee2833f..0000000 --- a/addon/ali1688/config/info.php +++ /dev/null @@ -1,20 +0,0 @@ - 'ali1688', - 'title' => '1688精选', - 'description' => '1688精选供应链,无货源备货,无人值守全自动营销', - 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件 - 'status' => 1, - 'author' => '', - 'version' => '1.0.0', - 'version_no' => '2024010114', - 'content' => '', -]; \ No newline at end of file diff --git a/addon/ali1688/config/menu_shop.php b/addon/ali1688/config/menu_shop.php deleted file mode 100644 index a0c2850..0000000 --- a/addon/ali1688/config/menu_shop.php +++ /dev/null @@ -1,91 +0,0 @@ - 'PROMOTION_ALI1688', - 'title' => '1688精选', - 'url' => 'ali1688://shop/order/lists', - 'parent' => 'PROMOTION_CENTER', - 'is_show' => 1, - 'sort' => 100, - 'child_list' => [ - [ - 'name' => 'ALI1688SHOP_ORDER', - 'title' => '采购订单', - 'url' => 'ali1688://shop/order/lists', - 'is_show' => 1, - 'sort' => 1, - ], - [ - 'name' => 'ALI1688SHOP_GOODS', - 'title' => '选品入库', - 'url' => 'ali1688://shop/goods/lists', - 'is_show' => 1, - 'sort' => 2, - 'child_list' => [ - [ - 'name' => 'ALI1688SHOP_SERVICE', - 'title' => '选品中心', - 'url' => 'ali1688://shop/goods/servicegoods', - 'is_show' => 0, - 'sort' => 1, - ], - [ - 'name' => 'ALI1688SHOP_ADD', - 'title' => '添加商品', - 'url' => 'ali1688://shop/goods/add', - 'is_show' => 0, - 'sort' => 2, - ], - [ - 'name' => 'ALI1688SHOP_REMOVE', - 'title' => '删除', - 'url' => 'ali1688://shop/goods/remove', - 'is_show' => 0, - 'sort' => 3, - ] - ] - ], - [ - 'name' => 'ALI1688GOODSTEMP', - 'title' => '价格模版', - 'url' => 'ali1688://shop/template/lists', - 'is_show' => 1, - 'sort' => 3, - 'child_list' => [ - [ - 'name' => 'ALI1688SHOP_ADDTEMPLATE', - 'title' => '添加模版', - 'url' => 'ali1688://shop/template/add', - 'is_show' => 0, - 'sort' => 1, - ], - [ - 'name' => 'ALI1688SHOP_EDITTEMPLATE', - 'title' => '编辑', - 'url' => 'ali1688://shop/template/edit', - 'is_show' => 0, - 'sort' => 1, - ], - [ - 'name' => 'ALI1688SHOP_REMOVETEMPLATE', - 'title' => '删除', - 'url' => 'ali1688://shop/template/remove', - 'is_show' => 0, - 'sort' => 1, - ] - ] - ], - [ - 'name' => 'ALI1688CONFIG', - 'title' => '系统设置', - 'url' => 'ali1688://shop/config/basics', - 'is_show' => 1, - 'sort' => 3, - 'child_list' => [] - ] - ] - ] -]; \ No newline at end of file diff --git a/addon/ali1688/event/Ali1688OrderBuy.php b/addon/ali1688/event/Ali1688OrderBuy.php deleted file mode 100644 index 8852e82..0000000 --- a/addon/ali1688/event/Ali1688OrderBuy.php +++ /dev/null @@ -1,25 +0,0 @@ -authBuyOrder($order_id); - } catch (\Exception $e) { - return $e->getMessage(); - } - } -} \ No newline at end of file diff --git a/addon/ali1688/event/Ali1688OrderRefund.php b/addon/ali1688/event/Ali1688OrderRefund.php deleted file mode 100644 index 1b15e8a..0000000 --- a/addon/ali1688/event/Ali1688OrderRefund.php +++ /dev/null @@ -1,19 +0,0 @@ -refundOrder($data); - return success(0, '供应链退款执行完成'); - } -} \ No newline at end of file diff --git a/addon/ali1688/event/AutoAddGoods.php b/addon/ali1688/event/AutoAddGoods.php deleted file mode 100644 index 625f2cf..0000000 --- a/addon/ali1688/event/AutoAddGoods.php +++ /dev/null @@ -1,31 +0,0 @@ -getConfig($siteId)['data']['value'] ?? []; - if (isset($config['isAutoGoodsAdd']) && (int)$config['isAutoGoodsAdd'] == 1) { - (new Goods($siteId))->AutoAddGoods($siteId); - } - } catch (\Exception $e) { - - } - return success(0, '添加成功'); - } -} \ No newline at end of file diff --git a/addon/ali1688/event/DeleteRecycleGoods.php b/addon/ali1688/event/DeleteRecycleGoods.php deleted file mode 100644 index f7f4afd..0000000 --- a/addon/ali1688/event/DeleteRecycleGoods.php +++ /dev/null @@ -1,28 +0,0 @@ -deleteRecycleGoods($params); - } catch (\Exception $e) { - - } - return success(0, '删除成功'); - } -} \ No newline at end of file diff --git a/addon/ali1688/event/Install.php b/addon/ali1688/event/Install.php deleted file mode 100644 index 319f066..0000000 --- a/addon/ali1688/event/Install.php +++ /dev/null @@ -1,23 +0,0 @@ -Notify($params); - } catch (\Exception $e) { - echo 'fial'; - } - } -} \ No newline at end of file diff --git a/addon/ali1688/event/OrderCreate.php b/addon/ali1688/event/OrderCreate.php deleted file mode 100644 index 5c4c255..0000000 --- a/addon/ali1688/event/OrderCreate.php +++ /dev/null @@ -1,16 +0,0 @@ -orderCreate($order); - } catch (\Exception $e) { - Log::debug('1688 - api请求下单失败:' . $e->getMessage()); - } - return success(0, '下单触发'); - } -} \ No newline at end of file diff --git a/addon/ali1688/event/OrderPay.php b/addon/ali1688/event/OrderPay.php deleted file mode 100644 index 0727a83..0000000 --- a/addon/ali1688/event/OrderPay.php +++ /dev/null @@ -1,25 +0,0 @@ -orderPay($order); - } catch (\Exception $e) { - Log::debug('1688 - api请求下单失败:' . $e->getMessage()); - } - return success(0, '下单触发'); - } -} diff --git a/addon/ali1688/event/ShowPromotion.php b/addon/ali1688/event/ShowPromotion.php deleted file mode 100644 index 952d6b7..0000000 --- a/addon/ali1688/event/ShowPromotion.php +++ /dev/null @@ -1,43 +0,0 @@ - [ - [ - //插件名称 - 'name' => 'ali1688', - //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具) - 'show_type' => 'tool', - //展示主题 - 'title' => '1688供应链', - //展示介绍 - 'description' => '1688精选商品供应链,自动营销,无需备货', - //展示图标 - 'icon' => 'addon/ali1688/icon.png', - //跳转链接 - 'url' => 'ali1688://shop/order/lists', - ] - ] - ]; - return $data; - } -} \ No newline at end of file diff --git a/addon/ali1688/event/UnInstall.php b/addon/ali1688/event/UnInstall.php deleted file mode 100644 index 525e2fa..0000000 --- a/addon/ali1688/event/UnInstall.php +++ /dev/null @@ -1,24 +0,0 @@ -requestApi('com.alibaba.product/alibaba.product.follow', ['productId' => $productId]); - $result = json_decode($result, true); - if ($result['code'] == 0) { - return true; - } else { - return $result; - } - } - - /*** - * 解除关注 - * @param $productId - * @return mixed|true - * @throws \Exception - */ - public function unfollowGoods($productId) - { - // 获取基本参数 - $result = $this->requestApi('com.alibaba.product/alibaba.product.unfollow.crossborder', ['productId' => $productId]); - $result = json_decode($result, true); - if ($result['code'] == 0) { - return true; - } else { - return $result; - } - } - - - //关键字搜索商品列表 - public function productlist($data) - { - $api = 'com.alibaba.fenxiao/jxhy.product.getPageList'; - if(isset($data['filters'])&&$data['filters']){ - $data['filters'] = json_encode(array_values($data['filters']),true); - }else{ - $data['filters'] = json_encode(['isOnePsaleFreePost']); - } - $result = json_decode($this->requestApi($api, $data), true); - if (isset($result['result']['success']) && isset($result['result']['result'])) { - $results = $result['result']['result']; - $itemId = array_column($results, 'itemId'); - $info = model('supply_goods_warehousing')->getColumn([['open_offer_id', 'in', $itemId], ['site_id', '=', $this->site_id]], 'open_offer_id', 'open_offer_id'); - foreach ($results as &$item) { - if (isset($info[$item['itemId']])) { - $item['is_warehousing'] = 1; - } else { - $item['is_warehousing'] = 0; - } - } - $result['result']['result'] = $results; - } - return $result; - } - - // public function productlist($data) - // { - // - // $data = $this->handleSearchData($data); - // $api = 'com.alibaba.fenxiao/alibaba.pifatuan.product.list'; - // $result = json_decode($this->requestApi($api, $data), true); - // if (isset($result['result']['success']) && isset($result['result']['result'])) { - // $results = $result['result']['result']['resultList']; - // $pageInfo = ['currentPage' => $result['result']['result']['pageIndex'], - // 'pageSize' => $result['result']['result']['sizePerPage'], - // 'totalRecords' => $result['result']['result']['totalRecords'], - // ]; - // $itemId = array_column($results, 'itemId'); - // $info = model('supply_goods_warehousing')->getColumn([['open_offer_id', 'in', $itemId], ['site_id', '=', $this->site_id]], 'open_offer_id', 'open_offer_id'); - // foreach ($results as &$item) { - // if (isset($info[$item['itemId']])) { - // $item['is_warehousing'] = 1; - // } else { - // $item['is_warehousing'] = 0; - // } - // } - // $result['result']['result'] = $results; - // $result['result']['pageInfo'] = $pageInfo; - // } - // return $result; - // } - - //获取商品详情 - public function productInfoGet($itemIds) - { - $this->gatewayHost = 'https://gw.open.1688.com/openapi/param2/2/'; - $api = 'com.alibaba.fenxiao/alibaba.pifatuan.product.detail.list'; - if (is_array($itemIds)) { - return json_decode($this->requestApi($api, ['offerIds' => json_encode($itemIds)]), true); - }else{ - return json_decode($this->requestApi($api, ['offerIds' => json_encode([$itemIds])]), true); - } - } - //获取物流模板详情 - //模板ID,(是否查询子模板,是否查询子模板费率)默认不查子模板 - public function productFreightTemplate($templateId,$querySubTemplate = true,$queryRate = true){ - - $api = 'com.alibaba.logistics/alibaba.logistics.myFreightTemplate.list.get'; - $arr = [ - 'templateId' => $templateId, - 'querySubTemplate' => $querySubTemplate, - 'queryRate' => $queryRate - ]; - - return json_decode($this->requestApi($api, $arr), true); - } - - - - //添加分销店铺(买家) - public function buyerOutshopAdd() - { - $api = 'com.alibaba.fenxiao/alibaba.fenxiao.buyer.outshop.add'; - return json_decode($this->requestApi($api, ['outShopCode' => $this->site_id, 'channel' => 'other']), true); - } - - //添加分销商品关系(买家) - public function buyerOutproductRelationAdd() - { - $api = 'com.alibaba.fenxiao/alibaba.fenxiao.buyer.outproduct.relation.add'; - $data = [ - 'channel' => 'other', - 'outShopCode' => $this->site_id, - 'outItemCode' => '6', - 'openOfferId' => 'BgnuDNkhiXPv88gpE3sfbA==', - ]; - return json_decode($this->requestApi($api, $data), true); - } - - - //根据地址解析地区码 - public function addressCodeParse($address) - { - $api = 'com.alibaba.trade/alibaba.trade.addresscode.parse'; - - return json_decode($this->requestApi($api, ['addressInfo' => $address]), true)['result']; - } - - //查询是否开通免密支付 - public function payProtocolPay() - { - $api = 'com.alibaba.trade/alibaba.trade.pay.protocolPay.isopen'; - - return json_decode($this->requestApi($api), true); - } - - //查询订单可以支持的支付渠道 - public function payWayQuery($orderId) - { - $api = 'com.alibaba.trade/alibaba.trade.payWay.query'; - - return json_decode($this->requestApi($api, ['orderId' => $orderId]), true); - } - - //发起免密支付 - public function protocolPayPreparePay($orderId) - { - $api = 'com.alibaba.trade/alibaba.trade.pay.protocolPay.preparePay'; - - return json_decode($this->requestApi($api, ['tradeWithholdPreparePayParam' => ['orderId' => $orderId]]), true); - } - - //获取交易订单的物流信息 - public function getLogisticsInfos($orderId) - { - $api = 'com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView'; - - return json_decode($this->requestApi($api, ['orderId' => $orderId]), true); - } - - //获取交易订单的物流跟踪信息 - public function getLogisticsTraceInfo($orderId) - { - $api = 'com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView'; - - return json_decode($this->requestApi($api, ['orderId' => $orderId, 'webSite' => '1688']), true); - } - - //查询退款退货原因(用于创建退款退货) - public function getRefundReasonList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.getRefundReasonList'; - - $array = [ - 'orderId' => $data['orderId'], - 'orderEntryIds' => $data['orderEntryIds'], - 'goodsStatus' => $data['goodsStatus'], - ]; - - return json_decode($this->requestApi($api, $array), true); - } - - //创建退款退货申请 - public function createRefund($data) - { - $api = 'com.alibaba.trade/alibaba.trade.createRefund'; - - $array = [ - 'orderId' => $data['orderId'], - 'orderEntryIds' => $data['orderEntryIds'], - 'disputeRequest' => $data['disputeRequest'], - 'applyPayment' => $data['applyPayment'], - 'applyCarriage' => $data['applyCarriage'], - 'applyReasonId' => $data['applyReasonId'], - 'description' => $data['description'], - 'goodsStatus' => $data['goodsStatus'], - ]; - - return json_decode($this->requestApi($api, $array), true); - } - - //上传退款退货凭证 - public function uploadRefundVoucher($imageData) - { - $api = 'com.alibaba.trade/alibaba.trade.uploadRefundVoucher'; - - return json_decode($this->requestApi($api, ['imageData' => $imageData]), true); - } - - //查询退款单列表(买家视角) - public function queryOrderRefundList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.buyer.queryOrderRefundList'; - - return json_decode($this->requestApi($api, $data), true); - } - - //查询退款单详情-根据订单ID(买家视角) - public function OpQueryBatchRefundByOrderIdAndStatus($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryBatchRefundByOrderIdAndStatus'; - - return json_decode($this->requestApi($api, $data), true); - } - - //查询退款单详情-根据退款单ID(买家视角) - public function OpQueryOrderRefund($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefund'; - - return json_decode($this->requestApi($api, $data), true); - } - - //退款单操作记录列表(买家视角) - public function OpQueryOrderRefundOperationList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefundOperationList'; - - return json_decode($this->requestApi($api, $data), true); - } - - //买家提交退款货信息 - public function refundReturnGoods($data) - { - $api = 'com.alibaba.trade:alibaba.trade.refund.returnGoods'; - return json_decode($this->requestApi($api, $data), true); - } - - //订购的订单列表 - public function pieceorderGet($data) - { - $api = 'cn.alibaba.open/alibaba.app.pieceorder.get'; - return json_decode($this->requestApi($api, $data), true); - } - - //app 在服务市场被订购的订单列表 - public function orderGet($data) - { - $api = 'cn.alibaba.open/app.order.get'; - return json_decode($this->requestApi($api, $data), true); - } - - //获取某个应用最近一个月的到期订单信息 - public function expireGet($data) - { - $api = 'cn.alibaba.open:app.expire.get'; - return json_decode($this->requestApi($api, $data), true); - } - //处理数据 - protected function handleSearchData(&$data){ - if(!isset($data['categoryId']) && $data['keywords'] == ''){ - $data['keywords'] = '零食'; - }else if(isset($data['categoryId']) && $data['categoryId'] == '' && $data['keywords'] == ''){ - $data['keywords'] = '零食'; - } - //默认一键包邮 - if(!isset($data['filterFreePostage'])){ - $data['filterFreePostage'] = true; - } - //是否包邮,是否一键代发,是否七天无理由退款,是否48小时发货 - $arr = ['filterFreePostage','filterYjdf','filter7dNoReasonReturn','filter48hShip']; - foreach($data as $key => $val){ - if(in_array($key,$arr)){ - $data[$key] = $data[$key] > 0 ? true : false; - } - } - return $data; - } -} diff --git a/addon/ali1688/model/CloudApi.php b/addon/ali1688/model/CloudApi.php deleted file mode 100644 index b26cea5..0000000 --- a/addon/ali1688/model/CloudApi.php +++ /dev/null @@ -1,594 +0,0 @@ -site_id = $site_id; - $this->public = [ - 'client_id' => $this->appKey, - 'client_secret' => $this->appSecret, - ]; - if (request()->param('code') && request()->param('state')) { - $state = explode('|', base64_decode(request()->param('state'))); - $this->site_id = $state[1]; - $this->getAccessToken(request()->param('code')); - if (!cache(request()->param('code'))) { - cache(request()->param('code'), 1); - $this->getAccessToken(request()->param('code')); - } else { - $this->access_token = Cache::store('redis_public')->get($this->site_id . '1688access_token'); - } - } else { - $this->refreshToken(); - } - } - - - /*** - * 获取授权码 - * @param $_uri - * @param $redirect_uri - * @return string - */ - public function getAuthorization_codeurl($_uri = '', $redirect_uri = '') - { - $redirect = $_uri ?: addon_url('ali1688/shop/auth/index'); - $codeData = [ - 'grant_type' => 'authorization_code', - 'client_id' => $this->appKey, - 'site' => 1688, - 'state' => base64_encode($redirect . '|' . $this->site_id), - 'redirect_uri' => $redirect_uri ?: $this->redirect_uri, - ]; - return 'https://auth.1688.com/oauth/authorize?' . http_build_query($codeData); - } - - /*** - * 查询是否免密支付 - * @return void - */ - public function getTradeIsopenProtocolPay() - { - $api = 'com.alibaba.trade/alibaba.trade.pay.protocolPay.isopen'; - $result = $this->requestApi($api, []); - $result = json_decode($result, true); - $data['ispayopen'] = false; - $data['signUrl'] = 'https://tradeconfig.1688.com/foundation/withhold_manage.htm'; - if (isset($result['success'])) { - $paymentAgreements = $result['result']['paymentAgreements']; - foreach ($paymentAgreements as $item) { - $data['signUrl'] = $item['signUrl']; - if ($item['bindingStatus'] == 'true' && $item['signedStatus'] == 'true') { - $data['ispayopen'] = true; - } else { - $data['ispayopen'] = false; - continue; - } - } - } - return $data; - } - - public function getAppBuyInfo() - { -// $api = 'cn.alibaba.open/alibaba.app.pieceorder.get'; - $api = 'cn.alibaba.open/app.order.get'; -// var_dump($this->config);die; -// var_dump(date('Y-m-d H:i:s',time()); -// var_dump(date('YmdHis',time())+'000+0800');die; - $result = $this->requestApi($api, [ - 'gmtCreate' => json_encode([date('YmdHis', $this->config['create_time']) . '000+0800', date('YmdHis', time()) . '000+0800']), -// 'gmtCreate'=>$this->config['create_time']*1000, -// 'memberId'=>$this->config['value']['memberId']??'', - 'aliId' => $this->config['value']['aliId'] ?? '', - 'bizStatusList' => json_encode(['S', 'E', 'B']) - ]); -// var_dump($this->config['value']['memberId'],$this->config['create_time'],$result);die; - $result = json_decode($result, true); - $data = [ - 'isbuyapp' => false, - 'expire_time' => -1, - ]; - if (isset($result['returnValue'])) { - return $result['returnValue']; - } - return $data; - } - - - /*** - * 地址解析 - * @param $addressInfo - * @return mixed - * @throws \Exception - */ - public function getTradeAddresscodeParse($addressInfo = '') - { - $api = 'com.alibaba.trade/alibaba.trade.addresscode.parse'; - $result = $this->requestApi($api, [ - 'addressInfo' => $addressInfo - ]); - $result = json_decode($result, true); - return $result; - } - - /*** - * 创建订单预览 - * @param $data - * @return mixed - * @throws \Exception - */ - public function createOrderPreview($data = []) - { - $api = 'com.alibaba.trade/alibaba.createOrder.preview'; - $result = $this->requestApi($api, $data); - $result = json_decode($result, true); - return $result; - } - - - /**** - * 创建订单 - * @param $data - * @return mixed - * @throws \Exception - */ - public function fastCreateOrder($data = []) - { - $api = 'com.alibaba.trade/alibaba.trade.fastCreateOrder'; - $result = $this->requestApi($api, $data); - $result = json_decode($result, true); - return $result; - } - - - /*** - * 取消订单 - * @param $orderID - * @return mixed - * @throws \Exception - */ - public function cancelOrder($tradeID, $cancelReason, $remark = '') - { - $api = 'com.alibaba.trade/alibaba.trade.cancel'; - $result = $this->requestApi($api, ['webSite' => 1688, 'tradeID' => implode(',', $tradeID), 'cancelReason' => $cancelReason, 'remark' => $remark]); - $result = json_decode($result, true); - return $result; - } - - /*** - * 获取1688分类 - * @param $categoryID - * @return mixed - * @throws \Exception - */ - public function getAlibabaCategory($categoryID = 0) - { - $Cache = Cache::get('1688categoryInfo' . $categoryID); - if ($Cache) { - return $Cache; - } - $api = 'com.alibaba.product/alibaba.category.get'; - $result = $this->requestApi($api, ['categoryID' => $categoryID]); - $result = json_decode($result, true); - if (isset($result['categoryInfo'])) { - if ($categoryID == 0) { - Cache::set('1688categoryInfo' . $categoryID, $result['categoryInfo'][0]['childCategorys']); - return $result['categoryInfo'][0]['childCategorys']; - } - } - return $result; - } - - - public function getAlibabaProductFilter() - { - $Cache = Cache::get('1688productFilter'); - if ($Cache) { - return $Cache; - } - $api = 'com.alibaba.fenxiao/jxhy.productFilter.get'; - $result = $this->requestApi($api); - $result = json_decode($result, true); - if (isset($result['result']['result'])) { - $result = $result['result']['result']; - Cache::set('1688productFilter', $result); - return $result; - } - return []; - } - - /*** - * 获取授权令牌 - * @param $code - * @return mixed - * @throws \Psr\SimpleCache\InvalidArgumentException - */ - public function getAccessToken($code = '') - { - $ConfigModel = new ConfigModel(); - $config = (array)$ConfigModel->getConfig($this->site_id)['data']['value']; - if ($code == '' && isset($config['expire_tiem']) && intval($config['expire_tiem']) > time()) { - $this->access_token = $config['access_token']; - Cache::store('redis_public')->set($this->site_id . '1688access_token', $this->access_token, $config['expire_tiem'] - time()); - return $this->access_token; - } - $url = "https://gw.open.1688.com/openapi/http/1/system.oauth2/getToken/{$this->appKey}"; - $urlData = array_merge($this->public, [ - 'grant_type' => 'authorization_code', - 'need_refresh_token' => true, - 'client_id' => $this->appKey, - 'client_secret' => $this->appSecret, - 'code' => $code, - 'redirect_uri' => addon_url('ali1688/shop/auth/info'), - ]); - if ($this->agent_baseURL) { - $baseData = [ - 'baseURL' => $url, - 'domain' => addon_url('ali1688/api/notify/index'), - 'site_id' => $this->site_id, - 'event' => 'AccessToken', - 'data' => json_encode(array_merge($this->public, $urlData)) - ]; - $result = $this->http_post_data($this->agent_baseURL, $baseData); - } else { - $result = http($url, 30, [], $urlData); - } - $json = json_decode($result, true); - if ($json && isset($json['access_token'])) { - $json['expire_tiem'] = time() + intval($json['expires_in']); - Cache::store('redis_public')->set($this->site_id . '1688access_token', $json['access_token'], intval($json['expires_in']) - 500); - $ConfigModel->setConfig(array_merge($config, $json), $this->site_id, 1); - $this->access_token = $json['access_token']; - } else { - return ''; - } - return $this->access_token; - } - - - /*** - * 重置TOKEN - * @return mixed|string - * @throws \Psr\SimpleCache\InvalidArgumentException - */ - public function refreshToken() - { - $ConfigModel = new ConfigModel(); - $config = $ConfigModel->getConfig($this->site_id)['data']['value']; - $this->config = $ConfigModel->getConfig($this->site_id)['data']; - if (isset($config['expire_tiem']) && intval($config['expire_tiem']) > time()) { - $this->access_token = $config['access_token']; - Cache::store('redis_public')->set($this->site_id . '1688access_token', $this->access_token, $config['expire_tiem'] - time()); - return $this->access_token; - } - $url = "https://gw.open.1688.com/openapi/param2/1/system.oauth2/getToken/{$this->appKey}"; - $urlData = array_merge($this->public, [ - 'grant_type' => 'refresh_token', - 'refresh_token' => $config['refresh_token'] ?? '', - 'client_id' => $this->appKey, - 'client_secret' => $this->appSecret, - ]); - if ($this->agent_baseURL) { - $baseData = [ - 'baseURL' => $url, - 'domain' => addon_url('ali1688/api/notify/index'), - 'site_id' => $this->site_id, - 'event' => 'AccessToken', - 'data' => json_encode(array_merge($this->public, $urlData)) - ]; - $result = $this->http_post_data($this->agent_baseURL, $baseData); - } else { - $result = http($url, 30, [], $urlData); - } - $json = json_decode($result, true); - if ($json && isset($json['access_token'])) { - $json['expire_tiem'] = time() + intval($json['expires_in']); - Cache::store('redis_public')->set($this->site_id . '1688access_token', $json['access_token'], intval($json['expires_in']) - 500); - $ConfigModel->setConfig(array_merge($config, $json), $this->site_id, 1); - $this->access_token = $json['access_token']; - } else { - return ''; - } - return $this->access_token; - } - - - //获取商品详情 - public function productInfoGet($data) - { - $api = 'com.alibaba.fenxiao/alibaba.fenxiao.productInfo.get'; - return json_decode($this->requestApi($api, ['openOfferId' => $data['open_offer_id']]), true); - } - - //添加分销店铺(买家) - public function buyerOutshopAdd() - { - $api = 'com.alibaba.fenxiao/alibaba.fenxiao.buyer.outshop.add'; - - return json_decode($this->requestApi($api, ['outShopCode' => $this->site_id, 'channel' => 'other']), true); - } - - //添加分销商品关系(买家) - public function buyerOutproductRelationAdd() - { - $api = 'com.alibaba.fenxiao/alibaba.fenxiao.buyer.outproduct.relation.add'; - $data = [ - 'channel' => 'other', - 'outShopCode' => $this->site_id, - 'outItemCode' => '6', - 'openOfferId' => 'BgnuDNkhiXPv88gpE3sfbA==', - ]; - return json_decode($this->requestApi($api, $data), true); - } - - - /*** - * 获取物流公司列表 - * @return array|mixed - * @throws \Psr\SimpleCache\InvalidArgumentException - */ - public function getLogisticCompanyList() - { - $LogisticCompanyList = Cache::store('redis_public')->get('OpQueryLogisticCompanyList'); - if ($LogisticCompanyList) { - return $LogisticCompanyList; - } else { - $api = 'com.alibaba.logistics/alibaba.logistics.OpQueryLogisticCompanyList.offline'; - $res = json_decode($this->requestApi($api), true); - if (isset($res['result']) && $res['result']) { - $list = array_column($res['result'], null, 'companyNo'); - Cache::store('redis_public')->set('OpQueryLogisticCompanyList', $list); - return $list; - } - return []; - } - } - - - //根据地址解析地区码 - public function addressCodeParse($address) - { - $api = 'com.alibaba.trade/alibaba.trade.addresscode.parse'; - return json_decode($this->requestApi($api, ['addressInfo' => $address]), true)['result']; - } - - //查询订单可以支持的支付渠道 - - /*** - * 查询支付渠道 - * @param $orderId - * @return mixed - * @throws \Exception - */ - public function payWayQuery($orderId) - { - $api = 'com.alibaba.trade/alibaba.trade.payWay.query'; - return json_decode($this->requestApi($api, ['orderId' => $orderId]), true); - } - - - /*** - * 发起在线支付 - * @param $orderIds - * @param $type PC或WIRELESS - * @return mixed - * @throws \Exception - */ - public function GroupPayUrl($orderIds, $type = 'PC') - { - $api = 'com.alibaba.trade/alibaba.trade.grouppay.url.get'; - return json_decode($this->requestApi($api, ['orderIds' => $orderIds, 'payPlatformType' => $type]), true); - } - - /*** - * 发起免密支付 - * @param $orderId - * @return mixed - * @throws \Exception - */ - public function protocolPayPreparePay($orderId) - { - $api = 'com.alibaba.trade/alibaba.trade.pay.protocolPay.preparePay'; - return json_decode($this->requestApi($api, ['tradeWithholdPreparePayParam' =>json_encode(['orderId' => $orderId])]), true); - } - - - //获取交易订单的物流信息 - public function getLogisticsInfos($orderId) - { - $api = 'com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView'; - return json_decode($this->requestApi($api, ['orderId' => $orderId]), true); - } - - //获取交易订单的物流跟踪信息 - public function getLogisticsTraceInfo($orderId) - { - $api = 'com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView'; - return json_decode($this->requestApi($api, ['orderId' => $orderId, 'webSite' => '1688']), true); - } - - //查询退款退货原因(用于创建退款退货) - public function getRefundReasonList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.getRefundReasonList'; - $array = [ - 'orderId' => $data['orderId'], - 'orderEntryIds' => $data['orderEntryIds'], - 'goodsStatus' => $data['goodsStatus'], - ]; - return json_decode($this->requestApi($api, $array), true); - } - - //创建退款退货申请 - public function createRefund($data) - { - $api = 'com.alibaba.trade/alibaba.trade.createRefund'; - $array = [ - 'orderId' => $data['orderId'], - 'orderEntryIds' => $data['orderEntryIds'], - 'disputeRequest' => $data['disputeRequest'], - 'applyPayment' => $data['applyPayment'], - 'applyCarriage' => $data['applyCarriage'], - 'applyReasonId' => $data['applyReasonId'], - 'description' => $data['description'], - 'goodsStatus' => $data['goodsStatus'], - ]; - return json_decode($this->requestApi($api, $array), true); - } - - //上传退款退货凭证 - public function uploadRefundVoucher($imageData) - { - $api = 'com.alibaba.trade/alibaba.trade.uploadRefundVoucher'; - return json_decode($this->requestApi($api, ['imageData' => $imageData]), true); - } - - //查询退款单列表(买家视角) - public function queryOrderRefundList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.buyer.queryOrderRefundList'; - return json_decode($this->requestApi($api, $data), true); - } - - //查询退款单详情-根据订单ID(买家视角) - public function OpQueryBatchRefundByOrderIdAndStatus($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryBatchRefundByOrderIdAndStatus'; - return json_decode($this->requestApi($api, $data), true); - } - - //查询退款单详情-根据退款单ID(买家视角) - public function OpQueryOrderRefund($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefund'; - return json_decode($this->requestApi($api, $data), true); - } - - //退款单操作记录列表(买家视角) - public function OpQueryOrderRefundOperationList($data) - { - $api = 'com.alibaba.trade/alibaba.trade.refund.OpQueryOrderRefundOperationList'; - return json_decode($this->requestApi($api, $data), true); - } - - //买家提交退款货信息 - public function refundReturnGoods($data) - { - $api = 'com.alibaba.trade:alibaba.trade.refund.returnGoods'; - return json_decode($this->requestApi($api, $data), true); - } - - //订购的订单列表 - public function pieceorderGet($data) - { - $api = 'cn.alibaba.open/alibaba.app.pieceorder.get'; - return json_decode($this->requestApi($api, $data), true); - } - - //app 在服务市场被订购的订单列表 - public function orderGet($data) - { - $api = 'cn.alibaba.open/app.order.get'; - return json_decode($this->requestApi($api, $data), true); - } - - - //获取某个应用最近一个月的到期订单信息 - public function expireGet($data) - { - $api = 'cn.alibaba.open/app.expire.get'; - return json_decode($this->requestApi($api, $data), true); - } - - /*** - * 获取签名 - * @param $path - * @param $postData - * @return string - */ - public function getSign($path, $postData) - { - $paramsToSign = array(); - foreach ($postData as $k => $v) { - $paramToSign = $k . $v; - array_push($paramsToSign, $paramToSign); - } - sort($paramsToSign); - $implodeParams = implode($paramsToSign); - $pathAndParams = $path . $implodeParams; - $sign = hash_hmac("sha1", $pathAndParams, $this->appSecret, true); - $signHexWithLowcase = bin2hex($sign); - $signHexUppercase = strtoupper($signHexWithLowcase); - return $signHexUppercase; - } - - /*** - * 请求接口 - * @param string $api - * @param $data - * @return array|bool|mixed|string - * @throws \Exception - */ - public function requestApi(string $api, $data = [], $extend = '') - { - $event = $api; - // 信息处理 获取请求签名 - $api .= '/' . $this->appKey; - $timestamp = round(microtime(true) * 1000); - $data['_aop_timestamp'] = $timestamp; - $data['access_token'] = $this->access_token; - $data['_aop_signature'] = $this->getSign($api, $data); - // 发起请求 - $link = $this->gatewayHost . $api; - if ($this->agent_baseURL) { - $bestdata = [ - 'domain' => config('domain.url') . '/ali1688/api/notify/index', - 'site_id' => $this->site_id, - 'event' => $event, - 'baseURL' => $link, - 'data' => json_encode(array_merge($this->public, $data)) - ]; - - return $this->http_post_data($this->agent_baseURL, $bestdata); - } else { - return http($link, 30, [], array_merge($this->public, $data)); - } - } - - public function http_post_data($url, $params = array()) - { - if (is_array($params)) { - $params = http_build_query($params, null, '&'); - } - $ch = curl_init(); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - $response = curl_exec($ch); - curl_close($ch); - return $response; - } -} diff --git a/addon/ali1688/model/Config.php b/addon/ali1688/model/Config.php deleted file mode 100644 index f26f3c1..0000000 --- a/addon/ali1688/model/Config.php +++ /dev/null @@ -1,67 +0,0 @@ -setConfig($data, '阿里1688系统设置', $is_use, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'ali1688']]); - return $res; - } - - /** - * 获取配置信息 - * @param int $site_id - * @return array - */ - public function getConfig($site_id) - { - $config = new ConfigModel(); - $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'ali1688']]); - return $res; - } - - - public function accessToken($site_id, $data = '') - { - $config = new ConfigModel(); - if ($data) { - $res = $config->setConfig($data, '阿里1688accessToken', 1, [['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', '1688accessToken']]); - return $res; - } - $res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', '1688accessToken']]); - if (empty($res['data']['value'])) { - return ''; - } else { - $data = $res['data']['value']; - if ($data['expire_tiem'] - time() >= 0) { - return $data['access_token']; - } else { - return ''; - } - } - } -} \ No newline at end of file diff --git a/addon/ali1688/model/Goods.php b/addon/ali1688/model/Goods.php deleted file mode 100644 index c0fa83d..0000000 --- a/addon/ali1688/model/Goods.php +++ /dev/null @@ -1,738 +0,0 @@ -site_id = $siteId; - } - - /** - * 取已入库的商品列表 - * @param array $search - * @return mixed - */ - public function getGoodsList($condition, $page, $page_size, $field = 'w.*,g.goods_image,g.brand_name,g.market_price,g.price,g.cost_price,g.goods_stock,g.site_name', $order = 'w.create_time desc') - { - $join = [ - ['goods g', 'g.goods_id=w.goods_id', 'left'] - ]; - $result = model('supply_goods_warehousing')->pageList($condition, $field, $order, $page, $page_size, 'w', $join); - return $this->success($result); - } - - - /*** - * 添加产品 - * @param $data - * @param $site_id - * @return array - */ - public function addGoods($goodsData, $site_id, $productID, $template_id = 0) - { - $follow = (new Choice($this->site_id))->followGoods($productID); - if ($follow == true) { - model('goods')->startTrans(); - try { - $this->site_id = $site_id; - // 判断:当前商品是否已经入库 - $isHas = (int)model("supply_goods_warehousing")->getValue([['open_offer_id', '=', $productID], ['site_id', '=', $this->site_id]], 'id'); - if ($isHas) throw new Exception('当前商品已经存在,您可以直接编辑商品或者删除重新添加'); - $goodsData['site_id'] = $site_id; - $goods_image = explode(',', $goodsData['goods_image']); - $goods_sku_data = json_decode($goodsData['goods_sku_data'], true); - $sku_image = array_column($goods_sku_data, 'sku_image'); - $goods_images = array_unique(array_merge($goods_image, $sku_image)); - $this->GooodsImgCheck($site_id, $goods_images);//验证图片上传 - $res = (new GoodsModel())->addGoods($goodsData); - if ($res['data']) { - model('supply_goods_warehousing')->add([ - 'site_id' => $this->site_id, - 'goods_id' => $res['data'], - 'open_offer_id' => $productID, - 'channel_type' => '1688', - 'third_party_name' => '1688精选', - 'template_id' => $template_id, - 'goods_name' => $goodsData['goods_name'], - 'create_time' => time(), - 'update_time' => time(), - ]); - model('goods')->commit(); - return $this->success('入库成功'); - } - throw new \Exception($res['message']); - } catch (\Exception $e) { - model('goods')->rollback(); - return $this->error('', $e->getMessage()); - } - } else { - return $this->error($follow); - } - } - - - /**** - * 检查图片同步 - * @param $goods_images - * @return void - */ - public function GooodsImgCheck($site_id, $goods_images) - { - $thumb_value = model('album_pic')->getColumn([['pic_path', 'in', $goods_images]], 'pic_path', 'pic_path'); - $goods_images = array_diff($goods_images, $thumb_value); - if ($goods_images) { - $album_id = model('album')->getValue([['site_id', '=', $site_id], ['type', '=', 'img']], 'album_id'); - $album_model = new Album(); - $cron = new Cron(); - foreach ($goods_images as $k => $v) { - $data = [ - "pic_path" => $v,//图片云存储 - "pic_name" => md5($v), - "pic_spec" => 'x', - "update_time" => time(), - "site_id" => $site_id, - "size" => 0, - "album_id" => $album_id, - "is_thumb" => 0, - ]; - $res = $album_model->addAlbumPic($data); - if ($res['code'] >= 0) { - $data["id"] = $res["data"]; - $cron->addCron(1, 1, '图片同步上传', 'AlbumUpload', time(), $res["data"]); - } - } - } - return $this->success('成功'); - } - - /*** - * 产品下架 - * @param $goodsData - * @param $site_id - * @param $productID - * @return void - */ - public function GooodsDelisting($site_id, $productID, $isDel = 0) - { - $where = [ - ['site_id', '=', $site_id], - ['open_offer_id', '=', $productID] - ]; - $goods_ids = model('supply_goods_warehousing')->getColumn($where, 'goods_id'); - if ($goods_ids) { - $goods_model = new GoodsModel(); - $data = [ - 'goods_state' => 0 - ]; - if ($isDel) { - $data['is_delete'] = 1; - $goods_model->modifyIsDelete($goods_ids, 1, $site_id); - } else { - $goods_model->modifyGoodsState($goods_ids, 0, $site_id); - } - model('supply_goods_warehousing')->update($data, $where); - } - return $this->success('下架成功'); - } - - /** - * @param $info - * @param array $goodsDetail 供应链商品信息,不存在则通过api接口获取 - * @return array - */ - public function refreshGoodsInfo($info, $goodsDetail = []) - { - model('goods')->startTrans(); - try { - $this->site_id = $info['site_id'] ?? $this->site_id; - $this->open_offer_id = $info['offer_id'] ?? 0; - // 判断:当前商品是否已经入库 - $goodsId = (int)model("supply_goods_warehousing")->getValue([['open_offer_id', '=', $this->open_offer_id], ['site_id', '=', $this->site_id]], 'goods_id'); - if ($goodsId <= 0) throw new Exception('商品不存在!'); - // 获取入库商品详情 - if (!$goodsDetail) $goodsDetail = (new Choice($this->site_id))->getGoodsDetail($this->open_offer_id); - $goodsData = $this->generateGoodsInfo($goodsDetail); - $goodsData['goods_id'] = $goodsId; - unset($goodsDetail['create_time']); - (new GoodsModel())->editGoods($goodsData); - // 添加入库记录 - model('supply_goods_warehousing')->update([ - 'update_time' => time(), - ], [ - ['goods_id', '=', $goodsId], - ['site_id', '=', $this->site_id] - ]); - model('goods')->commit(); - return $this->success('刷新成功'); - } catch (\Exception $e) { - model('goods')->rollback(); - return $this->error('', $e->getMessage()); - } - } - - /** - *商品入库 - 生成本平台商品信息 - * @param $goodsDetail - * @return array - */ - public function generateGoodsInfo($goodsDetail, $template_id = 0, $saleType = 'normal') - { - $time = time(); - $sku = []; - if (isset($goodsDetail['skuInfos'])) { - $sku = $goodsDetail['skuInfos'];// 商品规格列表 - } - $fileList = $goodsDetail['image']['images'] ?? [];// 商品主图列表 - $goods_info = model('supply_goods_warehousing')->getInfo(['open_offer_id' => $goodsDetail['productID']], 'w.goods_id,g.goods_name,g.brand_id,g.price,g.market_price,g.goods_name,g.price,g.goods_image,g.category_id,g.category_json', 'w', [['goods g', 'g.goods_id=w.goods_id', 'left']]); - $goods_category = []; - $category_id = ''; - $categoryjson = ''; - $brandId = ''; - $goods_id = ''; - $goods_name = $goodsDetail['subject']; - if ($goods_info) { - $categoryjson = $goods_info['category_json']; - $category_json = json_decode($categoryjson); - $category_id = $goods_info['category_id']; - $brandId = $goods_info['category_id']; - $goods_id = $goods_info['goods_id']; - $goods_name = $goods_info['goods_name']; - foreach ($category_json as $k => $v) { - if (!empty($v)) { - $category_list = model('goods_category')->getList([['category_id', 'in', $v]], 'category_name', 'level asc'); - $category_name = array_column($category_list, 'category_name'); - $category_name = implode('/', $category_name); - $goods_category[$k] = [ - 'id' => $v, - 'category_name' => $category_name - ]; - } - } - $goods_category = $goods_category; - } - $price_template = [ - 'price_set' => [ - 'multiple' => 35, - 'increase' => 0, - ], - 'title_set' => [], - 'sku_set' => [], - ]; - if ($template_id) { - $template = model('supply_price_template')->getInfo(['id' => $template_id]); - if ($template) { - $price_template['price_set'] = json_decode($template['price_set'], true); - $price_template['title_set'] = json_decode($template['title_set'], true); - $price_template['sku_set'] = json_decode($template['sku_set'], true); - } - } else { - $template = model('supply_price_template')->getInfo(['site_id' => $this->site_id, 'is_default' => 1]); - if ($template) { - $price_template['price_set'] = json_decode($template['price_set'], true); - $price_template['title_set'] = json_decode($template['title_set'], true); - $price_template['sku_set'] = json_decode($template['sku_set'], true); - } - } - // 数据处理 - 库存 - $saleInfo = $goodsDetail['saleInfo']; - $stock = $saleInfo['amountOnSale']; - $img_url = 'https://cbu01.alicdn.com/'; - // 数据处理 - 主图列表 - $goodsImage = implode(',', array_map(function ($data) use ($img_url) { - return $img_url . $data; - }, $fileList)); - $default_img = explode(',', $goodsImage)[0]; - $attributes = array_column($sku, 'attributes'); - $_spec = []; - foreach ($attributes as $key => $val) { - foreach ($val as $k => $v) { - $attributeID = $v['attributeID']; - $skuImageUrl = $v['skuImageUrl'] ?? ''; - $spec_value_name = $v['attributeValue']; - if (!isset($_spec[$attributeID])) { - $_spec[$attributeID] = [ - 'spec_id' => $attributeID, - 'spec_name' => $v['attributeName'], - 'value' => [$spec_value_name => [ - 'spec_id' => $attributeID, - 'spec_name' => $v['attributeName'], - 'spec_value_name' => $v['attributeValue'], - 'spec_value_id' => $attributeID + $key, - 'image' => $skuImageUrl ? $img_url . $skuImageUrl : '' - ]] - ]; - } else { - $_spec[$attributeID]['value'][$spec_value_name] = [ - 'spec_id' => $attributeID, - 'spec_name' => $v['attributeName'], - 'spec_value_name' => $v['attributeValue'], - 'spec_value_id' => $attributeID + $key, - 'image' => $skuImageUrl ? $img_url . $skuImageUrl : '' - ]; - } - } - } - if (count($sku) > 0) {//多规格 - $skuList = $this->generateGoodsSkuInfo($sku, $goods_id, $saleInfo, $price_template, $default_img, $img_url, $_spec, $goodsDetail['productID'], $saleType); - $one_sku = $sku[0]; - if ($saleType == 'normal') { - $minOrderQuantity = 1; - $consignPrice = $one_sku['retailPrice']; - $is_free_shipping = 1; - } else { - $minOrderQuantity = $saleInfo['minOrderQuantity']; - $consignPrice = $one_sku['jxhyPfPrice']; - $is_free_shipping = 0; - } - } else { //单规格 - if ($saleType == 'normal') { - $minOrderQuantity = 1; - $consignPrice = $saleInfo['retailprice']; - $is_free_shipping = 1; - } else { - $minOrderQuantity = $saleInfo['minOrderQuantity']; - $consignPrice = $saleInfo['jxhyPfPrice']; - $is_free_shipping = 0; - } - $startQuantity = array_column($goodsDetail['saleInfo']['priceRanges'], 'startQuantity'); - $price = $saleInfo['priceRanges'][array_search(min($startQuantity), $startQuantity)]['price'] ?? $saleInfo['priceRanges'][0]['price']; - $image = $goodsDetail['image']['images'][0]; - - //单规格单独去拼装 - $skuList = [$this->fictitiousGoodsSkuInfo($goods_id, $goods_name, $price, $consignPrice, $stock, $image, $img_url, $goodsDetail)]; - $one_sku = [ - 'retailPrice' => $consignPrice, - 'consignPrice' => $consignPrice, - 'price' => $price - ]; - } - $_spec = array_map(function ($val) { - return [ - 'spec_id' => $val['spec_id'], - 'spec_name' => $val['spec_name'], - 'value' => array_values($val['value']) - ]; - }, $_spec); - if ($_spec) { - $this->goods_spec_format = json_encode(array_values($_spec), JSON_UNESCAPED_UNICODE); - } - $goods_attr_format = []; - if ($goodsDetail['attributes']) { - foreach ($goodsDetail['attributes'] as $key => $val) { - $goods_attr_format[] = [ - 'attr_class_id' => $key, - 'attr_id' => $val['attributeID'], - 'attr_name' => $val['attributeName'], - 'attr_value_id' => $val['attributeID'], - 'attr_value_name' => $val['value'], - 'sort' => $key, - ]; - } - } - $goods_content = $goodsDetail['description'];//商品详情 - $categoryjson = json_encode($category_id);//商品分类 - $mul_inc_price = $price_template['price_set']['multiple'] ?? 0; - if ($mul_inc_price) { - $inc_price = ($consignPrice * $mul_inc_price / 100); - $inc_price = $inc_price < 0.01 ? 0.01 : $inc_price; - } else { - $inc_price = ($price_template['price_set']['increase'] ?: $consignPrice * 5 / 100); - $inc_price = $inc_price < 0.01 ? 0.01 : $inc_price; - } - $price = $consignPrice + $inc_price; - $title_set = $price_template['title_set'] ?? ''; - if ($title_set) { - if (isset($title_set['delete_keywords']) && $title_set['delete_keywords']) { - $goods_name = str_replace($title_set['delete_keywords'], '', $goods_name); - } - $goods_name = $title_set['prefix'] . $goods_name . $title_set['suffix']; - } - // 生成商品数据 - return [ - 'goods_id' => $goods_id,// 商品名称 - 'goods_name' => $goods_name,// 商品名称 - 'goods_class' => 1,// 【固定不变】商品种类1.实物商品2.虚拟商品3.卡券商品4.服务项目5.卡项商品 - 'goods_class_name' => '实物商品',// 【固定不变】商品种类 - 'goods_attr_class' => 0,// 【固定不变】商品类型id - 'goods_attr_name' => '',// 【固定不变】商品类型名称 - 'site_id' => $this->site_id,// 店铺ID - 'goods_image' => $goodsImage,// 商品主图路径 多图以英文逗号隔开 - 'introduction' => '',//描述 - 'sku_list' => $skuList,//描述 - 'goods_content' => $goodsDetail['description'] ?: $goods_content,// 商品详情 - 'goods_state' => $goodsDetail['status'] == 'published' ? 1 : 0,// 【固定不变】 - 'category_id' => $category_id,// 商品分类id,逗号隔开 - 'category_json' => $categoryjson,// 分类json字符串 - 'goods_category' => $goods_category,// 分类json字符串 - 'brand_id' => $brandId,// 商品品牌id - 'brand_name' => $goodsDetail['brand'] ?? '',// 品牌名称 - - 'price' => moneyFormat(round($price, 1)),// 商品价格(取第一个sku) 对应-建议零售价 - 'cost_price' => $one_sku['consignPrice'] ?? $one_sku['price'] ?? 0,// 成本价(取第一个sku) 对应-结算价 - 'goods_stock' => $stock,// 商品库存(总和) - 'is_free_shipping' => $is_free_shipping,// 是否包邮 - 'goods_spec_format' => $this->goods_spec_format,//json_encode($this->goods_spec_format, JSON_UNESCAPED_UNICODE),// 多规格信息 - 'create_time' => $time,// 添加时间 - 'modify_time' => $time,// 修改时间 - 'support_trade_type' => 'express', // 【固定不变】支持的配送方式 仅 快递发货 - 'market_price' => moneyFormat(round($price + $price * 35 / 100, 1)),//划线价 - 'sale_num' => 0, - 'virtual_sale' => $goodsDetail['bookedCount'] ?? 0, - 'real_stock' => $stock, - 'label_id' => '', - 'timer_on' => 0, - 'timer_off' => '', - 'is_consume_discount' => 0, - 'goods_stock_alarm' => 0, - 'shipping_template' => 0, - 'goods_attr_format' => json_encode($goods_attr_format, JSON_UNESCAPED_UNICODE), - 'keywords' => '', - 'unit' => $saleInfo['unit'], - 'video_url' => $goodsDetail['mainVedio'] ?? '', - 'sort' => 0, - 'sale_show' => 0, - 'stock_show' => 0, - 'market_price_show' => 0, - 'barrage_show' => 0, - 'goods_service_ids' => '', - 'sale_channel' => 'all', - 'sale_store' => 'all', - 'is_limit' => 0, - 'limit_type' => 1, - 'max_buy' => '', - 'min_buy' => $minOrderQuantity, - 'recommend_way' => 0, - 'is_zmxx' => 0, - 'is_unify_pirce' => 1, - 'qr_id' => '', - 'goods_sku_data' => json_encode($skuList, JSON_UNESCAPED_UNICODE), - ]; - } - - /** - * Common: 商品入库 - 商品分类处理,查询本平台分类ID;如果不存在则添加 - * @param $cate - * @return int[]|string[] - */ - private function getThisPlatformCateIds($cate) - { - $cateNames = array_column($cate, 'name'); - $hasList = model('goods_category')->getColumn([ - ['category_name', 'in', $cateNames], - ['site_id', '=', $this->site_id] - ], 'category_name', 'category_id'); - // 数量不对 缺少分类ID - if (count($hasList) < count($cate)) { - $createCateData = array_filter(array_map(function ($apiCate) use ($hasList) { - if (!in_array($apiCate['name'], $hasList)) { - return [ - 'site_id' => $this->site_id, - 'category_name' => $apiCate['name'], - 'image' => imgSeeLink($apiCate['iconPath'] ?? ''), - 'level' => 1, - 'commission_rate' => 0.0, - ]; - } - return []; - }, $cate)); - model('goods_category')->addList($createCateData); - return $this->getThisPlatformCateIds($cate); - } - return array_keys($hasList); - } - - /** - * Common: 商品入库 - 商品品牌处理,查询本平台品牌ID;如果不存在则添加 - * @param $brandName - * @return int - */ - private function getThisPlatformBrandId($brandName = '') - { - $brandId = 0; - if (!empty($brandName)) { - $brandId = (int)model('goods_brand')->getValue([ - ['brand_name', 'in', $brandName], - ['site_id', '=', $this->site_id] - ], 'brand_id'); - // 数量不对 缺少分类ID - if ($brandId <= 0) { - model('goods_brand')->add([ - 'brand_name' => $brandName, - 'site_id' => $this->site_id, - 'create_time' => time() - ]); - return $this->getThisPlatformBrandId($brandName); - } - } - return $brandId; - } - - //1688单规格拼装数据 - private function fictitiousGoodsSkuInfo($goodsId, $goodsName, $price, $retailPrice, $amountOnSale, $image, $img_url, $goodsDetail = [], $saleType = '') - { - $offerId = $goodsDetail['productID']; - return [ - 'site_id' => $this->site_id,// 所属店铺id - 'goods_id' => $goodsId,// 商品id - 'sku_id' => '',// 商品id - 'sku_name' => $goodsName,// 商品sku名称 - 'sku_no' => '',// 商品sku编码 - 'price' => round(moneyFormat($price), 1, PHP_ROUND_HALF_EVEN), // sku单价 - 'cost_price' => $retailPrice,//sku成本价 - 'stock' => $amountOnSale, // 商品sku库存 - 'sku_image' => $img_url . $image, - 'sku_images' => $img_url . $image, - 'goods_class' => 1, - 'goods_class_name' => '实物商品', - 'create_time' => time(), - 'modify_time' => time(), - 'goods_attr_class' => 0, - 'is_default' => 0, - 'spec_name' => '', // - 'real_stock' => $amountOnSale, // 实物库存 - 'sku_spec_format' => '', - 'goods_supplier_format' => json_encode([ - 'offerId' => $offerId, - 'skuId' => '', - 'spec_id' => '', - 'saleType' => $saleType, - ]),//第三方扩展数据,因为是单规格为空 - // 必须内容 - 'market_price' => moneyFormat(round($price + $price * 35 / 100, 1)), - 'discount_price' => moneyFormat(round($price, 1)), // sku单价 - 'weight' => 0, - 'volume' => 0, - 'sale_num' => 0, - 'virtual_sale' => 0, - 'fenxiao_price' => 0, - 'stock_alarm' => '', - ]; - } - - //获取批发价 - private function getRetailPrice($saleInfo) - { - //获取最小起订量 - $minOrderQuantity = $saleInfo['minOrderQuantity']; - $startQuantity_num = array_column($saleInfo['priceRanges'], 'startQuantity'); - $num = array_search($minOrderQuantity, $startQuantity_num); - return $saleInfo['priceRanges'][$num]['price'] ?? $saleInfo['priceRanges'][0]['price']; - } - - /** - * Common: 商品入库 - 生成本平台商品规格信息 - * @param $goodsDetail - * @param $goodsId - * @return array|array[] - */ - private function generateGoodsSkuInfo($sku, $goodsId, $saleInfo, $price_template, $defaultSkuImage, $img_url, $_spec, $offerId, $saleType = '') - { - // 获取默认主图 - // 处理规格信息 生成本平台规矩信息列表 - $skuList = array_map(function ($skuItem) use ($goodsId, $saleInfo, $defaultSkuImage, $price_template, $img_url, $_spec, $offerId, $saleType) { -// if (!isset($skuItem['retailPrice'])) { -// var_dump(555); -// $skuItem['retailPrice'] = $skuItem['retailPrice']; -// // $skuItem['retailPrice'] = !isset($skuItem['price']) ? $skuItem['consignPrice'] : $skuItem['price']; -// }else if(!isset($skuItem['price'])){ -// var_dump(666); -// $skuItem['price'] = $skuItem['retailPrice']; -// } - if ($saleType == 'normal') { - $consignPrice = $skuItem['retailPrice']; - } else { - $consignPrice = $skuItem['jxhyPfPrice']; - } - //进一位 -// $retailPrice = ceil($skuItem['retailPrice'] * 10) / 10; -// if (!isset($skuItem['retailPrice'])) { -// $skuItem['retailPrice'] = $skuItem['consignPrice']; -// } - $mul_inc_price = $price_template['price_set']['multiple'] ?? 0; - if ($mul_inc_price) { - $inc_price = ($skuItem['retailPrice'] * $mul_inc_price / 100); - $inc_price = $inc_price < 0.01 ? 0.01 : $inc_price; - } else { - $inc_price = ($price_template['price_set']['increase'] ?: $skuItem['retailPrice'] * 5 / 100); - $inc_price = $inc_price < 0.01 ? 0.01 : $inc_price; - } - $sku_set = $price_template['sku_set'] ?? ''; - $price = $consignPrice + $inc_price; - // $price = $skuItem['price'] + $inc_price; - // $saleType=$saleInfo['saleType']??'batch'; - // if($saleType=='batch'){ - // $price = $price / $saleInfo['minOrderQuantity']; - // $saleInfo['minOrderQuantity']=1; - // $skuItem['consignPrice']=$skuItem['consignPrice']/$saleInfo['minOrderQuantity']; - // } - $price = ceil($price * 10) / 10; - $attributes = $skuItem['attributes']; - $attributes = array_map(function ($item) use ($_spec) { - $spec_value_id = $_spec[$item['attributeID']]['value'][$item['attributeValue']]['spec_value_id']; - return [ - 'spec_id' => $item['attributeID'], - 'spec_name' => $item['attributeName'], - 'spec_value_id' => $spec_value_id, - 'spec_value_name' => $item['attributeValue'], - 'image' => '', - ]; - }, $attributes); - $sku_name = $skuItem['cargoNumber']; - if ($sku_set) { - if (isset($sku_set['delete_keywords']) && $sku_set['delete_keywords']) { - $sku_name = str_replace($sku_set['delete_keywords'], '', $sku_name); - } - $sku_name = $sku_set['prefix'] . $sku_name . $sku_set['suffix']; - } - // 规格列表 - return [ - 'site_id' => $this->site_id,// 所属店铺id - 'goods_id' => $goodsId,// 商品id - 'sku_id' => '',// 商品id - 'sku_name' => $sku_name,// 商品sku名称 - 'sku_no' => $skuItem['skuCode'],// 商品sku编码 - // 'price' => round(moneyFormat($price), 1, PHP_ROUND_HALF_EVEN), // sku单价 - // 'cost_price' => $skuItem['consignPrice'],//sku成本价 - // 'cost_price' => !isset($skuItem['price']) ? $skuItem['consignPrice'] : $skuItem['price'],//sku成本价 - 'price' => $price, // sku单价 - 'cost_price' => $consignPrice,//sku成本价 - 'stock' => $skuItem['amountOnSale'], // 商品sku库存 - 'sku_image' => isset($skuItem['attributes'][0]['skuImageUrl']) ? $img_url . $skuItem['attributes'][0]['skuImageUrl'] : $defaultSkuImage, - 'sku_images' => isset($skuItem['attributes'][0]['skuImageUrl']) ? $img_url . $skuItem['attributes'][0]['skuImageUrl'] : $defaultSkuImage, - 'goods_class' => 1, - 'goods_class_name' => '实物商品', - 'create_time' => time(), - 'modify_time' => time(), - 'goods_attr_class' => 0, - 'is_default' => 0, - 'spec_name' => $skuItem['cargoNumber'] ?? '', // - 'real_stock' => $skuItem['amountOnSale'], // 实物库存 - 'sku_spec_format' => json_encode($attributes), - 'goods_supplier_format' => json_encode([ - 'offerId' => $offerId, - 'skuId' => $skuItem['skuId'], - 'spec_id' => $skuItem['specId'], - 'saleType' => $saleType, - ]), - // 必须内容 - 'market_price' => moneyFormat(round($price + $price * 35 / 100, 1)), - 'discount_price' => moneyFormat(round($price, 1)), // sku单价 - 'weight' => 0, - 'volume' => 0, - 'sale_num' => 0, - 'virtual_sale' => 0, - 'fenxiao_price' => 0, - 'stock_alarm' => '', - ]; - }, $sku); - if ($goodsId) { - $goods_model = new GoodsModel(); - $goods_sku_list = $goods_model->getGoodsSkuList([['goods_id', '=', $goodsId], ['site_id', '=', $this->site_id]], "sku_id,sku_name,sku_no,sku_spec_format,price,market_price,cost_price,stock,weight,volume,sku_image,sku_images,goods_spec_format,spec_name,stock_alarm,is_default,goods_supplier_format", '')['data']; - $mpsku_arr = array_column($skuList, null, 'sku_no'); - foreach ($goods_sku_list as $key => &$skuItem) { - if (isset($mpsku_arr[$skuItem['sku_no']])) { - $skuItem = array_merge($skuItem, $mpsku_arr[$skuItem['sku_no']]); - } - } - return $goods_sku_list; - } - return $skuList ?? []; - } - - /** - * Common: 商品入库 - 刷新规格信息 - * Author: wu-hui - * Time: 2023/09/04 11:27 - * @param $skuList - * @param $goodsId - * @throws \Exception - */ - private function refreshGoodsSkuInfo($skuList, $goodsId) - { - // 获取已经存在的规格 - $hasList = (array)model('goods_sku')->getColumn([ - ['goods_id', '=', $goodsId], - ['site_id', '=', $this->site_id] - ], 'sku_no', 'sku_id'); - $skuIds = array_flip($hasList);// 键值互换 以sku编码为键 id为值 - // 循环处理 - $insertData = array_column($skuList, null, 'sku_no');// 默认添加全部 - $updateData = []; - $deleteData = $skuIds;// 默认删除全部 - foreach ($skuList as $skuItem) { - // 判断:如果当前规格已经存在,执行刷新 并且移除删除和添加内容 - if (in_array($skuItem['sku_no'], $hasList)) { - $skuItem['sku_id'] = $skuIds[$skuItem['sku_no']]; - $updateData[] = $skuItem; - - unset($deleteData[$skuItem['sku_no']]); - unset($insertData[$skuItem['sku_no']]); - } - } - // 进行对应的操作 先删除、在修改、最后添加 - model('goods_sku')->delete([ - ['goods_id', '=', $goodsId], - ['sku_no', 'in', array_values($deleteData)], - ['site_id', '=', $this->site_id] - ]); - // 修改 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'goods_sku', 'pk' => 'sku_id'])); - $goodsSkuModel->saveAll($updateData); - // 添加 - model('goods_sku')->addList(array_values($insertData)); - } - - public function getDefaultSkuImage() - { - $url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http"; - $url .= "://" . $_SERVER['SERVER_NAME'] . '/public/static/img/default_img/square.png'; - return $url; - } - - /*** - * 系统自动入库 - * @return void - */ - public function AutoAddGoods($siteId = '') - { - return $this->success(); - } - - /*** - * 删除供应链商品 - * @param $params - * @return array - */ - public function deleteRecycleGoods($params) - { - $info = model('supply_goods_warehousing')->getList([['site_id', '=', $params['site_id']], ['goods_id', 'in', $params['goods_ids']]], 'goods_id,open_offer_id'); - if ($info) { - $follow = (new Choice($this->site_id)); - foreach ($info as $k => $v) { - $follow->unfollowGoods($v['open_offer_id']); //解除关注 - } - } - model('supply_goods_warehousing')->delete([['site_id', '=', $params['site_id']], ['goods_id', 'in', $params['goods_ids']]]); - return $this->success('删除成功'); - } -} diff --git a/addon/ali1688/model/NotifyChange.php b/addon/ali1688/model/NotifyChange.php deleted file mode 100644 index 48f9c4a..0000000 --- a/addon/ali1688/model/NotifyChange.php +++ /dev/null @@ -1,332 +0,0 @@ -site_id = $data['site_id']; - $config = $ConfigModel->getConfig($data['site_id'])['data']['value']; - $msg = json_decode($data['message'], true); - file_put_contents($msg['type'] ?? '1688' . '.txt', json_encode($data)); - if (!empty($config) && isset($msg['userInfo']) && isset($config['memberId']) && $config['memberId'] == $msg['userInfo']) { - switch ($msg['type']) { - //以下功能已完成 - case 'LOGISTICS_BUYER_VIEW_TRACE': //物流变更 - $res = $this->LOGISTICS_BUYER_VIEW_TRACE($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_SELLER_MODIFY_ADRESS': //商家修改订单地址(买家视角) - $res = $this->ORDER_BUYER_VIEW_ORDER_SELLER_MODIFY_ADRESS($msg); - break; - case 'ORDER_BUYER_VIEW_PART_PART_SENDGOODS': //1688订单部分发货 - $res = $this->ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS($msg, 2); - break; - case 'ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS': //商品发货 - $res = $this->ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS($msg); - break; - case 'ORDER_BUYER_VIEW_BUYER_MAKE': //订单创建成功 - $res = $this->ORDER_BUYER_VIEW_BUYER_MAKE($msg); - break; - case 'ORDER_BATCH_PAY': //批量支付状态 - $res = $this->ORDER_BATCH_PAY($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_PAY': //1688交易付款(买家视角 - $res = $this->ORDER_BUYER_VIEW_ORDER_PAY($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_SUCCESS': //交易成功 - $res = $this->ORDER_BUYER_VIEW_ORDER_SUCCESS($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_SELLER_CLOSE': //1688订单关闭 - $res = $this->ORDER_BUYER_VIEW_ORDER_SELLER_CLOSE($msg); - break; - case 'PRODUCT_RELATION_VIEW_PRODUCT_DELETE': //1688产品删除(关系用户视角) - case 'PRODUCT_RELATION_VIEW_PRODUCT_AUDIT': //1688产品审核下架(关系用户视角) - case 'PRODUCT_RELATION_VIEW_PRODUCT_EXPIRE': //1688产品下架(关系用户视角) - case 'PRODUCT_PFT_OFFER_QUIT': //商品下架 - $res = $this->PRODUCT_PFT_OFFER_QUIT($msg); - break; - //未开发不重要 - case 'LOGISTICS_MAIL_NO_CHANGE': //快递号修改 - $res = $this->LOGISTICS_MAIL_NO_CHANGE($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_BUYER_REFUND_IN_SALES': //1688订单售中退款(买家视角) - case 'ORDER_BUYER_VIEW_ORDER_REFUND_AFTER_SALES': //1688订单售后退款(买家视角) - $res = $this->ORDER_BUYER_VIEW_ORDER_REFUND($msg); - break; - case 'PRODUCT_PFT_OFFER_PRICE_MODIFY': //精选货源商品价格变动消息 - case 'PRODUCT_PRODUCT_INVENTORY_CHANGE': //1688商品库存变更消息 - case 'PRODUCT_RELATION_VIEW_PRODUCT_CHANGE': //商品变更消息(关系用户视角、包含所有商品变更动作) - case 'PRODUCT_RELATION_VIEW_PRODUCT_REPOST': //1688产品上架(关系用户视角) - case 'PRODUCT_RELATION_VIEW_PRODUCT_NEW_OR_MODIFY': //1688产品新增或修改(关系用户视角) - $res = $this->PRODUCT_PFT_OFFER_PRICE_MODIFY($msg); - break; - case 'ORDER_BUYER_VIEW_ORDER_PRICE_MODIFY': //1688修改订单价格 - $res = $this->ORDER_BUYER_VIEW_ORDER_PRICE_MODIFY($msg); - break; - default: - $res = 'ok'; - break; - } - } - } else { - $res = 'ok'; - } - echo $res; - } - - - /**** - * 商品下架 - * @param $msg - * @return void - */ - public function PRODUCT_PFT_OFFER_QUIT($msg) - { - $goodsModel = new Goods($this->site_id); - $isDel = 0; - if ($msg['type'] == 'PRODUCT_PFT_OFFER_QUIT') {//产品下架 - $offerId = $msg['data']['offerId']; - } else if ($msg['type'] == 'PRODUCT_RELATION_VIEW_PRODUCT_EXPIRE') {//1688产品下架(关系用户视角) - $offerId = $msg['data']['productIds']; - } else if ($msg['type'] == 'PRODUCT_RELATION_VIEW_PRODUCT_DELETE') {//产品删除 - $isDel = 1; - $offerId = $msg['data']['productIds']; - } else if ($msg['type'] == 'PRODUCT_RELATION_VIEW_PRODUCT_AUDIT') {//产品下架 - $offerId = $msg['data']['productIds']; - } - $goodsModel->GooodsDelisting($this->site_id, $offerId, $isDel); - return 'ok'; - } - - /*** - * 商品信息变动 - * @param $msg - * @return string - */ - public function PRODUCT_PFT_OFFER_PRICE_MODIFY($msg) - { - - return 'ok'; - } - - /*** - * 物流变更 - * @param $msg - * @return string - */ - public function LOGISTICS_BUYER_VIEW_TRACE($msg) - { - $logistics = $msg['data']['OrderLogisticsTracingModel'] ?? ''; - if ($logistics) { - $goodsModel = new Order($this->site_id); - if ($logistics['statusChanged'] == 'CONSIGN') {//订单发货 - $goodsModel->SendDelivery($logistics, $this->site_id, 'CONSIGN'); - } else if ($logistics['statusChanged'] == 'SIGN') { //订单签收 - - } - } - return 'ok'; - } - - - /*** - * 快递号修改 - * @param $msg - * @return string - */ - public function LOGISTICS_MAIL_NO_CHANGE($msg) - { - - return 'ok'; - } - - /** - * 批量支付状态 - * @param $msg - * @return string - */ - public function ORDER_BATCH_PAY($msg) - { - $batchPay = $msg['data']['batchPay'] ?? []; - $goodsModel = new Order($this->site_id); - foreach ($batchPay as $key => $value) { - if ($value['status'] == 'successed') { - $where = [ - 'third_order' => $value['orderId'], - 'channel_type' => 1688, - ]; - $data = [ - 'pay_status' => 1, - 'pay_time' => time(), - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - } - } - return 'ok'; - } - - - /*** - * 商品发货 - * @param $msg - * @return string - * @throws \Exception - */ - public function ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS($msg, $order_status = 1) - { - $goodsModel = new Order($this->site_id); - $third_order = $msg['data']['orderId'] ?? 0; - if ($third_order) { - $where = [ - 'third_order' => $third_order, - 'channel_type' => 1688, - ]; - $data = [ - 'order_status' => $order_status, - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - } - return 'ok'; - } - - - /*** - * 下单成功 - * @param $msg - * @return string - * @throws \Exception - */ - public function ORDER_BUYER_VIEW_BUYER_MAKE($msg) - { - $goodsModel = new Order($this->site_id); - $third_order = $msg['data']['orderId'] ?? 0; - if ($third_order) { - $where = [ - 'third_order' => $third_order, - 'channel_type' => 1688, - ]; - $data = [ - 'status' => 1, - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - } - return 'ok'; - } - - /*** - * 订单付款 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_PAY($msg) - { - - $goodsModel = new Order($this->site_id); - $third_order = $msg['data']['orderId'] ?? 0; - if ($third_order) { - $where = [ - 'third_order' => $third_order, - 'channel_type' => 1688, - ]; - $data = [ - 'three_pay_status' => 1, - 'pay_time' => time(), - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - } - return 'ok'; - } - - - /*** - * 订单价格修改 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_PRICE_MODIFY($msg) - { - return 'ok'; - } - - /*** - * 交易订单关闭 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_SELLER_CLOSE($msg) - { - $goodsModel = new Order($this->site_id); - $third_order = $msg['data']['orderId'] ?? 0; - if ($third_order) { - $where = [ - 'third_order' => $third_order, - 'channel_type' => 1688, - ]; - $data = [ - 'order_status' => -1, - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - $cron_model = new Cron(); - $order_id = model('supply_order')->getValue($where, 'order_id'); - $cron_model->addCron(1, 0, '订单自动关闭', 'CronOrderClose', time(), $order_id); - } - return 'ok'; - } - - /*** - * 商家修改订单地址 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_SELLER_MODIFY_ADRESS($msg) - { - return 'ok'; - } - - /*** - * 交易成功 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_SUCCESS($msg) - { - $goodsModel = new Order($this->site_id); - $third_order = $msg['data']['orderId'] ?? 0; - if ($third_order) { - $where = [ - 'third_order' => $third_order, - 'channel_type' => 1688, - ]; - $data = [ - 'order_status' => 10, - ]; - $goodsModel->updateOrderState($where, $data, $this->site_id); - } - return 'ok'; - } - - - /*** - * 交易退款售后 - * @param $msg - * @return string - */ - public function ORDER_BUYER_VIEW_ORDER_REFUND($msg) - { - return 'ok'; - } -} diff --git a/addon/ali1688/model/Order.php b/addon/ali1688/model/Order.php deleted file mode 100644 index a902e20..0000000 --- a/addon/ali1688/model/Order.php +++ /dev/null @@ -1,706 +0,0 @@ -site_id = $site_id; - } - - /*** - * 发起免密支付 - * @param $site_id - * @param $id - * @return array - * @throws \Exception - */ - public function noPasswordPay($site_id, $id) - { - $result = model('supply_order')->getInfo(['order_id' => $id]); - if ($result['three_pay_status'] == 0 && $result['status'] == 1) { - $cloudApi = new CloudApi($site_id); - $res = $cloudApi->protocolPayPreparePay($result['third_order']); - if ($res['success']) { - $data = ['three_pay_status' => 1]; - model('supply_order')->update($data, ['order_id' => $id]); - return $this->success('', '支付成功'); - } else { - $code = [ - 'USER_BALANCE_NOT_ENOUGH' => '用户余额不足' - ]; - return $this->error(-1, $code[$res['code']] ?? '发生未知错误'); - } - } else { - return $this->error(-1, '该订单已支付,或未下单!'); - } - } - - - /*** - * 获取在线支付链接 - * @param $site_id - * @param $id - * @return array|void - */ - public function onlinePay($site_id, $id) - { - $result = model('supply_order')->getInfo(['order_id' => $id]); - if ($result['three_pay_status'] == 0 && $result['status'] == 1) { - $cloudApi = new CloudApi($site_id); - $order_ids = [$result['third_order']]; - $res = $cloudApi->GroupPayUrl(json_encode($order_ids)); - if ($res['success']) { - $res['order_money'] = $result['result_total_pay']; - return $this->success($res); - } else { - return $this->error(-1, $res['message']); - } - } else { - return $this->error(-1, '该订单已支付,或未下单!'); - } - } - - - /*** - * 取消订单 - * @param $site_id - * @param $id - * @return array - * @throws \Exception - */ - public function cancelOrder($site_id, $id, $cancelReason) - { - $result = model('supply_order')->getInfo(['order_id' => $id]); - if ($result['three_pay_status'] == 0 && $result['status'] == 1) { - $cloudApi = new CloudApi($site_id); - $order_ids = [$result['third_order']]; - $res = $cloudApi->cancelOrder($order_ids, $cancelReason); - if ($res['success']) { - $data = ['reason_failure' => $cancelReason, 'remark' => $cancelReason, 'order_status' => -1]; - model('supply_order')->update($data, ['order_id' => $id]); - return $this->success('', '取消成功'); - } else { - return $this->error(-1, $res['errorMessage']); - } - } else { - return $this->error(-1, '该订单已支付,或未下单!'); - } - } - - - /*** - * 创建订单浏览 - * @param $order_no - * @return void - */ - public function createOrderPpreview($orderId = 0) - { - try { - // 获取订单商品信息 - if ($orderId <= 0) throw new Exception("订单或者门店不存在!"); - $goodsData = $this->getOrderArrangeInfo($orderId); - if (empty($goodsData)) throw new Exception("当前信息不存在!"); - $cloudApi = new CloudApi($this->site_id); - $buyOrderInfo = $cloudApi->createOrderPreview($goodsData); - if (isset($buyOrderInfo['orderPreviewResuslt'])) { - $totalPay = 0; - $sumCarriage = 0; - $cargoList = []; //待整改与实时下单有冲突 - foreach ($buyOrderInfo['orderPreviewResuslt'] as $k => $v) { - $totalPay += $v['sumPayment']; - $sumCarriage += $v['sumCarriage']; - $cargoList = array_merge($cargoList, $v['cargoList']); - } - $orderRecordUpdateData['cost_price'] = $totalPay / 100; - $orderRecordUpdateData['result_express_fee'] = $sumCarriage / 100;// 快递费 - $orderRecordUpdateData['result_total_pay'] = $totalPay / 100;// 支付金额,包含快递费 - $orderRecordUpdateData['status'] = 1;// 下单成功 - $orderRecordUpdateData['result_id'] = 0; - $orderRecordUpdateData['result_user_id'] = 0; - $orderRecordUpdateData['result_status'] = 1;// 订单状态 1:待支付 2:支付完成 - $orderRecordUpdateData['order_sub_list'] = $cargoList;// 子订单列表 - $result = $this->success(); - } else { - throw new Exception($buyOrderInfo['error_message'] ?? '未知错误'); - } - } catch (\Exception $e) { - $message = $e->getMessage(); - $orderRecordUpdateData['result_id'] = $buyOrderInfo['request_id'] ?? ''; - $orderRecordUpdateData['status'] = 0; - $orderRecordUpdateData['reason_failure'] = $message; - $result = [ - 'code' => -2, - 'msg' => $message, - ]; - } - // 修改下单记录信息 - $this->updateOrderInfo($orderRecordUpdateData, $orderId); - return $result; - } - - - /*** - * 获取订单信息 - * @param $order_id - * @param $field - * @return mixed - */ - public function getOrderInfo($order_id, $field = '*') - { - $result = model('supply_order')->getInfo(['order_id' => $order_id], $field); - return $result; - } - - /** - * 获取供应链订单列表 - * @param $search - * @return array - */ - public function getOrderList($search) - { - // 查询条件 - $where = [ - ['site_id', '=', $search['site_id']] - ]; - if (!empty($search['order_no'])) $where[] = ['order_no', '=', $search['order_no']]; - if (!empty($search['result_id'])) $where[] = ['result_id', '=', $search['result_id']]; - if (strlen($search['status'] ?? '') > 0) $where[] = ['status', '=', $search['status']]; - // 其他查询配置 - $result = model('supply_order')->pageList($where, '*', 'order_id DESC', $search['page'] ?? 1); - // 基本信息处理 - return $this->success($result ?? []); - } - - - /*** - * 获取订单子订单列表 - * @param $site_id - * @param $order_id - * @return array - */ - public function getSubOrder($site_id, $order_id, $search = []) - { - $where = [ - ['sup.order_id', '=', $order_id], - ['sup.site_id', '=', $site_id], - ]; - $join = [ - [ - 'order_goods og', - 'sup.order_id = og.order_id', - 'inner' - ] - ]; - $field = [ - 'og.order_goods_id', - 'og.sku_name', - 'og.sku_image', - 'og.sku_no', - 'og.cost_price', - 'sup.id', - 'sup.order_id', - 'sup.result_id', - 'sup.result_express_company', - 'sup.result_express_number', - 'sup.result_express_status', - 'sup.result_express_time', - 'sup.result_product_specs_id', - 'sup.result_quantity', - 'sup.result_seller_remarks', - ]; - // 获取订单商品信息 - $result = model('supply_sub_order')->pageList($where, $field, 'id DESC', $search['page'] ?? 1, $search['page_size'] ?? 1, 'sup', $join); - return $this->success($result ?? []); - } - - /*** - * 获取供应链信息 - * @param $orderId - * @param $field - * @return mixed - */ - public function getOrderSupplyGoods($orderId, $field = ['og.order_goods_id', 'og.sku_id', 'og.num', 'og.goods_id', 'o.buyer_message']) - { - $where = [ - ['og.order_id', '=', $orderId], - ['fg.goods_id', '>', 0] - ]; - $join = [ - [ - 'supply_goods_warehousing fg', - 'og.goods_id = fg.goods_id', - 'right' - ], - [ - 'order o', - 'o.order_id=og.order_id', - 'inner' - ] - ]; - $goods_order_sku = model('order_goods')->getList($where, $field, '', 'og', $join); - // 获取订单商品信息 - return $goods_order_sku; - } - - /** - * 下单记录 - 创建初始化下单记录 - * @param $order - * @throws Exception - */ - public function orderPay($order) - { - $orderId = (int)$order['order_id'] ?? 0; - $this->site_id = (int)$order['site_id'] ?? 0; - if ($orderId <= 0 || $this->site_id <= 0) return $this->error('订单或者店铺不存在!'); - // 获取订单商品信息 仅获取供应链的商品 - $orderGoodsList = $this->getOrderSupplyGoods($orderId); - if (count($orderGoodsList)) { - // 记录当前订单信息 - $res = $this->updateOrderState(['site_id' => $this->site_id, 'order_id' => $orderId], - [ - 'order_no' => $order['order_no'], - 'buyer_shop_id' => $order['site_id'], - 'order_name' => $order['order_name'], - 'order_from' => $order['order_from'], - 'pay_status' => 1, - 'buyer_uid' => $order['member_id'], - 'name' => $order['name'], - 'mobile' => $order['mobile'] ?: $order['telephone'], - 'province_id' => $order['province_id'], - 'city_id' => $order['city_id'], - 'district_id' => $order['district_id'], - 'address' => $order['address'], - 'buyer_message' => $order['buyer_message'], - 'full_address' => $order['full_address'], - 'goods_num' => $order['goods_num'], - 'pay_money' => $order['pay_money'], - 'pay_time' => $order['pay_time'] - ], - $this->site_id - ); - $ConfigModel = new ConfigModel(); - $config = $ConfigModel->getConfig($this->site_id)['data']['value']; - $isAutoBuyOrder = $config['isAutoBuyOrder'] ?? 0; - if ($isAutoBuyOrder == 1) { - $cron = new Cron(); - $cron->addCron(1, 1, '1688自动下单', 'CronAutoAliOrderBuy', time(), $orderId); - } - } - } - - /** - * Common: 下单记录 - 创建初始化下单记录 - * @param $order - * @throws Exception - */ - public function orderCreate($order) - { - $orderId = (int)$order['order_id'] ?? 0; - $this->site_id = (int)$order['site_id'] ?? 0; - if ($orderId <= 0 || $this->site_id <= 0) return $this->error('订单或者店铺不存在!'); - if (isset($order['create_data']['shop_goods_list']['goods_list'])) { - $goods_ids = array_column($order['create_data']['shop_goods_list']['goods_list'], 'goods_id'); - if (model('supply_goods_warehousing')->getCount([['goods_id', 'in', $goods_ids]], 'id') > 0) { - $data = [ - 'site_id' => $order['site_id'], - 'order_id' => $order['order_id'], - 'order_no' => $order['order_no'] ?? '', - 'order_from' => $order['create_data']['order_from'] ?? '',//订单来源 - 'order_from_name' => $order['create_data']['order_from_name'] ?? '',//来源名称 - 'channel_type' => '1688', - 'status' => -1,// 订单状态:-1=待请求下单,0=下单失败,1=下单成功 - 'pay_status' => 0,// 是否扣款 - 'create_time' => time(), - 'goods_money' => $order['create_data']['goods_money'], - 'delivery_money' => $order['create_data']['delivery_money'], - 'invoice_money' => $order['create_data']['invoice_money'], - 'order_money' => $order['create_data']['order_money'], - 'adjust_money' => $order['create_data']['adjust_money'], - 'balance_money' => $order['create_data']['balance_money'], - 'pay_money' => $order['create_data']['pay_money'], - ]; - $this->createRecordAdd($data); - } - } - } - - /*** - * 订单状态更新 - * @param $condition - * @param $data - * @param $site_id - * @return int - */ - public function updateOrderState($condition, $data, $site_id = 0) - { - $res = model('supply_order')->update($data, $condition); - return $res; - } - - /** - * 下单记录 - 记录下单日志 - * @param $data - */ - private function createRecordAdd($data) - { - $isHas = (int)model('supply_order')->getValue([ - ['order_id', '=', $data['order_id']] - ], 'order_id'); - if ($isHas <= 0) { - model('supply_order')->add($data); - } - } - - - /** - * 下单-自动请求供应链下单 - * @param $siteId - */ - public function authBuyOrder($order_id = 0) - { - // 获取最早的、未进行下单请求的订单id - // 存在id 进行自动下单操作 - if ($order_id > 0) { - return $this->orderCreateRequest($order_id); - } else { - return $this->error('1688订单号不存在'); - } - } - - /** - * 下单 - 请求进行下单操作 - * @param $order - */ - public function orderCreateRequest($orderId = 0) - { - try { - // 获取订单商品信息 - if ($orderId <= 0) return $this->error(-1, '订单或者门店不存在!'); - $goodsData = $this->getOrderArrangeInfo($orderId); - if (empty($goodsData)) return $this->error(-1, '当前信息不存在'); - $cloudApi = new CloudApi($this->site_id); - $buyOrderInfo = $cloudApi->fastCreateOrder($goodsData); - if (isset($buyOrderInfo['result']['totalSuccessAmount'])) { - $result = $buyOrderInfo['result']; - $cargoList = json_decode($goodsData['cargoParamList'], true); - $cargoList = array_column($cargoList, null, 'specId'); - foreach ($this->skuList as $k => $v) { - $offer = json_decode($v['goods_supplier_format'], true); - $cargoList[$offer['spec_id']]['cost_price'] = $v['cost_price']; - $cargoList[$offer['spec_id']]['sku_id'] = $v['sku_id']; - $cargoList[$offer['spec_id']]['sku_no'] = $v['sku_no']; - $cargoList[$offer['spec_id']]['goods_id'] = $v['goods_id']; - $cargoList[$offer['spec_id']]['third_order'] = $result['orderId']; - } - $totalPay = $result['totalSuccessAmount'] ?? 0; - $sumCarriage = $result['postFee']; - $orderRecordUpdateData['third_order'] = $result['orderId']; - $orderRecordUpdateData['cost_price'] = $totalPay / 100; - $orderRecordUpdateData['result_express_fee'] = $sumCarriage / 100;// 快递费 - $orderRecordUpdateData['result_total_pay'] = $totalPay / 100;// 支付金额,包含快递费 - $orderRecordUpdateData['status'] = 1;// 下单成功 - $orderRecordUpdateData['result_id'] = 0; - $orderRecordUpdateData['result_user_id'] = 0; - $orderRecordUpdateData['result_status'] = 1;// 订单状态 1:待支付 2:支付完成 - $orderRecordUpdateData['order_sub_list'] = array_values($cargoList);// 子订单列表 - $this->updateOrderInfo($orderRecordUpdateData, $orderId); - if (isset($result['failedOfferList'])) { - foreach ($result['failedOfferList'] as $k => $v) { - model('supply_sub_order')->update(['result_express_status' => -1, 'result_exception_reason' => $v['errorMessage']], ['result_product_specs_id' => $v['specId']]); - } - } - $result = $this->success('下单成功'); - } else { - return $this->error('发生错误', $buyOrderInfo['message'] ?? '未知错误'); - } - } catch (\Exception $e) { - $message = $e->getMessage(); - $orderRecordUpdateData['result_id'] = $buyOrderInfo['request_id'] ?? ''; - $orderRecordUpdateData['status'] = 0; - $orderRecordUpdateData['reason_failure'] = $message; - $result = [ - 'code' => -2, - 'msg' => $message, - ]; - $this->updateOrderInfo($orderRecordUpdateData, $orderId); - } - // 修改下单记录信息 - return $result; - } - - - /** - * Common: 订单处理 - 供应链订单信息修改 - * @param $orderRecordUpdateData - * @param $orderId - * @throws \Exception - */ - public function updateOrderInfo($orderRecordUpdateData, $orderId) - { - // 判断:是否存在子订单信息 - $orderSubList = $orderRecordUpdateData['order_sub_list'] ?? []; - unset($orderRecordUpdateData['order_sub_list']); - if (count($orderSubList) > 0) $this->updateOrCreateSubOrder($orderSubList, $orderId);//创建子订单 - // 修改订单信息 - $orderRecordUpdateData['update_time'] = time(); - model('supply_order')->update($orderRecordUpdateData, [ - ['order_id', '=', $orderId] - ]); - } - - /** - * 订单处理 - 处理子订单信息 - * @param $orderSubList - * @param $orderId - * @throws \Exception - */ - public function updateOrCreateSubOrder($orderSubList, $orderId) - { - // 循环处理子订单信息 - $subList = array_map(function ($item) use ($orderId) { - return [ - 'site_id' => $this->site_id, - 'order_id' => $orderId, - 'result_exception_reason' => '',// 请求结果:订单异常原因 1:恢复正常 2:需要换货 3:需要补发 4:地址错误 5:疫情停发 - 'result_express_company' => '',// 请求结果:快递公司 - 'result_express_number' => '',// 请求结果:快递单号 - 'result_express_status' => 0,// 请求结果:订单物流状态 1 待发货 2 已发货 3 已签收 4 拒收 5 已退款 6 申请退款 7 同意申请 8 拒绝申请 - 'result_express_time' => '',// 发货时间 - 'result_id' => $item['offerId'] ?? '', - 'goods_id' => $item['goods_id'] ?? '', - 'sku_id' => $item['sku_id'] ?? '', - 'result_sub_id' => $item['third_order'] ?? '',// 请求结果:子订单id - 'result_price' => $item['cost_price'] ?? 0,// 请求结果:下单时的商品结算价格 - 'result_product_specs_id' => $item['specId'] ?? '',// 请求结果:商品规格编号 - 'result_quantity' => $item['quantity'] ?? 1,// 请求结果:购买单品数量 - 'result_seller_remarks' => $item['sku_no'] ?? '',// 请求结果:卖家备注 - ]; - }, $orderSubList); - // 获取已经存在的子订单信息 - $deleteData = (array)model('supply_sub_order')->getColumn([ - ['order_id', '=', $orderId], - ], 'order_id'); - if ($deleteData) { - // 进行对应的操作 先删除、在修改、最后添加 - model('supply_sub_order')->delete([ - ['order_id', '=', $orderId], - ['site_id', '=', $this->site_id] - ]); - } - $goodsSkuModel = (new NewBaseModel(['table_name' => 'supply_sub_order'])); - $goodsSkuModel->saveAll($subList); - return $subList; - } - - - /*** - * 整理下单信息 - * @param $orderId 下单ID - * @param $flow general(创建大市场订单),fenxiao(创建分销订单),saleproxy流程将校验分销关系,paired(火拼下单),boutiquefenxiao(精选货源分销价下单,采购量1个使用包邮), boutiquepifa(精选货源批发价下单,采购量大于2使用). flow如果为空的情况,会比价择优预览,并返回最优下单方式flow - * @param $openOfferId 是否加密 - * @return array - */ - public function getOrderArrangeInfo($orderId, $flow = 'boutiquefenxiao', $openOfferId = 0) - { - $orderGoodsList = $this->getOrderSupplyGoods($orderId); - // 获取规格信息 - $skuIds = array_column($orderGoodsList, 'sku_id'); - $skuList = model('goods_sku')->getList([ - ['sku_id', 'in', $skuIds] - ], ['sku_id', 'goods_id', 'sku_no', 'cost_price', 'goods_supplier_format']); - // 规格对应的数量信息 - $nums = array_column($orderGoodsList, 'num', 'sku_id'); - $order = model('order')->getInfo([['order_id', '=', $orderId]], ['site_id', 'order_no', 'province_id', 'city_id', 'district_id', 'address', 'name', 'telephone', 'mobile', 'full_address', 'buyer_message']); - $this->orderInfo = $order; - $this->skuList = $skuList; - $quantity = []; - if (array_sum(array_values($nums)) > 2) { - $flow = 'boutiquepifa'; - } - if (empty($order)) return []; - $this->site_id = $order['site_id']; - // 获取收货地址信息 - $fullAddress = $order['full_address'] ?? '';// 收货地区信息 格式:省-市-区 - $fullAddress = explode('-', $fullAddress); - $orderInfo = [ - 'flow' => $flow, - 'outOrderId' => $order['order_no'], - 'message' => $order['buyer_message'], - 'addressParam' => [ - 'fullName' => mb_strlen($order['name'], 'UTF-8') > 1 ? $order['name'] : $order['name'] . $order['name'],//收货人姓名 - 'mobile' => $order['mobile'], //手机 - 'phone' => $order['telephone'] ?: $order['mobile'], //电话 - 'provinceText' => $fullAddress[0] ?? '',//省份文本 - 'cityText' => $fullAddress[1] ?? '',//市文本 - 'areaText' => $fullAddress[2] ?? '', //区文本 - 'townText' => '', //镇文本 - 'address' => str_replace($order['full_address'] . '-', '', $order['address']), //街道地址 - 'postCode' => 000000,//邮编 - ], - 'cargoParamList' => array_map(function ($skuItem) use ($nums, $quantity) { - $offer = json_decode($skuItem['goods_supplier_format'], true); - $quantity[$offer['spec_id']] = (int)$nums[$skuItem['sku_id']]; - $data = [ - 'offerId' => $offer['offerId'], - 'specId' => $offer['spec_id'], - 'quantity' => (int)$nums[$skuItem['sku_id']], - ]; - if (isset($offer['openOfferId'])) { - $data['openOfferId'] = $offer['openOfferId']; - } - return $data; - }, $skuList), - ]; - $this->quantity_temp = $quantity; - $orderInfo['addressParam'] = json_encode($orderInfo['addressParam']); - $orderInfo['cargoParamList'] = json_encode($orderInfo['cargoParamList']); - return $orderInfo; - } - - /** - * 退款 - 根据子订单发起退款申请 - * @param $data - */ - public function refundOrder($data) - { - try { - - - } catch (\Exception $e) { - Log::debug('1688供应链 - 退款成功 - 供应链退款失败原因:' . $e->getMessage()); - } - return []; - } - - /*** - * 发货 - * @param $params - * @return void - */ - public function SendDelivery($params, $site_id, $type = 'CONSIGN') - { - if ($params && isset($params['orderLogsItems']) && $type == 'CONSIGN') { - $orderLogsItems = $params['orderLogsItems']; - $sub_order_ids = array_column($orderLogsItems, 'orderEntryId'); - $order_ids = array_column($orderLogsItems, 'orderId'); - $where = [ - ['sub.site_id', '=', $site_id], - ['sub.result_sub_id', 'in', $sub_order_ids] - ]; - $join = [ - ['order_goods og', 'sub.order_id=og.order_id', 'inner'] - ]; - $info = model('supply_sub_order')->getList($where, 'og.order_goods_id,og.order_id,og.site_id', '', 'sub', $join); - if ($info) { - $cloudApi = new CloudApi($site_id); - $logislist = $cloudApi->getLogisticCompanyList(); - $logis = $logislist[$params['cpCode']] ?? []; - if ($logis) { - $companyName = $logis['companyName']; - $companyNo = $logis['companyNo']; - } else { - $companyName = '其他物流'; - $companyNo = 'OTHER'; - } - $express_company_id = $this->getExpressCompanyId($site_id, $companyName, $companyNo); - $delivery_no = $params['mailNo'] ?? ''; - $user_info = model('user')->getInfo([['site_id', '=', $site_id], ['app_module', '=', 'shop']]); - $log_data = [ - 'uid' => $user_info['uid'], - 'nick_name' => $user_info['username'], - 'action' => '商家对订单进行了发货', - 'action_way' => 2, - ]; - $order_model = new OrderModel(); - foreach ($info as $k => $v) { - $data = array( - 'type' => 'manual', //发货方式(手动发货、电子面单) - 'order_goods_ids' => $v['order_goods_id'],//商品id - 'express_company_id' => $express_company_id,//物流公司 - 'delivery_no' => $delivery_no,//快递单号 - 'order_id' => $v['order_id'],//订单id - 'delivery_type' => 1,//是否需要物流 - 'site_id' => $site_id, - 'template_id' => 0,//电子面单模板id - 'user_info' => $user_info - ); - model('supply_sub_order')->update(['result_express_number' => $delivery_no, 'result_express_time' => time(), 'result_express_company' => $companyName], [ - 'site_id' => $site_id, - 'result_sub_id' => $v['result_sub_id'] - ]); - $order_model->orderGoodsDelivery($data, 1, $log_data); - } - } - } - return $this->success(); - } - - /*** - * 自动添加物流信息 - * @param $site_id - * @param $company_name - * @param $express_no - * @return mixed - */ - public function getExpressCompanyId($site_id, $company_name, $express_no) - { - $where = [ - ['site_id', '=', $site_id], - ['express_no', '=', $express_no] - ]; - $express_company_id = model('express_company')->getValue($where, 'company_id'); - if (empty($express_company_id)) { - $data = [ - 'site_id' => $this->site_id, - 'company_name' => $company_name,//物流公司名称 - 'sort' => 0,//排序 - 'logo' => '',//logo - 'url' => '',//网址 - 'express_no' => $express_no,//编码 - 'express_no_kd100' => strtolower($express_no),//编码(快递100) - 'express_no_cainiao' => strtoupper($express_no),//编码(菜鸟) - 'express_no_alipay' => strtoupper($express_no),//编码(支付宝) - 'content_json' => '',//打印内容 - 'background_image' => '',//打印背景图 - 'font_size' => 14,//打印字体大小 单位px - 'width' => 0,//显示尺寸宽度 px - 'height' => 0,//显示尺寸高度 px - 'scale' => 1,//真实尺寸(mm)与显示尺寸(px)的比例 - 'create_time' => time(), - 'is_electronicsheet' => 0,//是否支持电子面单 - 'print_style' => 0,//电子面单打印风格 - ]; - $template_model = new ExpressCompanyTemplate(); - $res = $template_model->addExpressCompanyTemplate($data); - if ($res['code'] >= 0) { - //添加店铺模版 - $express_company_model = new ExpressCompany(); - $company = $express_company_model->addExpressCompany(['site_id' => $site_id, 'company_id' => $res['data']]); - $express_company_id = $company['data']; - Cache::tag("cache_tableexpress_company")->clear(); - } - } - return $express_company_id; - } -} diff --git a/addon/ali1688/model/Template.php b/addon/ali1688/model/Template.php deleted file mode 100644 index da216b1..0000000 --- a/addon/ali1688/model/Template.php +++ /dev/null @@ -1,120 +0,0 @@ -site_id = $siteId; - $this->model = model('supply_price_template'); - } - - - /** - * Common: 获取模板列表 - * Author: wu-hui - * Time: 2023/08/30 16:54 - * @param array $search - * @return mixed - */ - public function getTemplateList($search = []) - { - // 查询条件 - $where = [ - ['site_id', '=', $search['site_id']] - ]; - if (!empty($search['filter']['title'])) $where[] = ['title', 'like', '%' . $search['filter']['title'] . '%']; - // 其他查询配置 - $field = 'id,title,price_set,category_id,goods_class,alipaycategory_id,template_id,is_default,create_time,update_time'; - $result = $this->model->pageList($where, $field, 'id DESC', $search['page'] ?? 1); - return $this->success($result ?? []); - } - - /** - * 添加模板 - */ - public function addTemplate($data) - { - if ($data['price_set']) $data['price_set'] = json_encode($data['price_set']); - if ($data['title_set']) $data['title_set'] = json_encode($data['title_set']); - if ($data['sku_set']) $data['sku_set'] = json_encode($data['sku_set']); - if(!isset($data['listing_mode'])){ - $data['listing_mode'] = 1;//不上架 - } - $result = $this->model->add($data); - if ($result) return json(['code' => '0', 'message' => '添加成功']); - else return json(['code' => '400', 'message' => '添加失败']); - } - - /** - * 获取模板详情 - * @param $id - * @return void - * - */ - public function templateInfo($id) - { - if (!intval($id)) { - return json(['code' => '400', 'message' => '模板ID错误']); - } - $where = ['id' => $id]; - $field = 'id,title,category_id,goods_class,alipaycategory_id,template_id,price_set,listing_mode,title_set,sku_set'; - $data = $this->model->getInfo($where, $field); - - if ($data) { - if ($data['price_set']) $data['price_set'] = json_decode($data['price_set'], true); - if ($data['title_set']) $data['title_set'] = json_decode($data['title_set'], true); - if ($data['sku_set']) $data['sku_set'] = json_decode($data['sku_set'], true); - } - - return $data; - } - - /** - * @return void - * 修改模板 - */ - public function editTemplate($data) - { - $id = $data['id']; - if (!intval($id)) { - return json(['code' => '400', 'message' => '模板ID错误']); - } else { - unset($data['id']); - } - if ($data['price_set']) $data['price_set'] = json_encode($data['price_set']); - if ($data['title_set']) $data['title_set'] = json_encode($data['title_set']); - if ($data['sku_set']) $data['sku_set'] = json_encode($data['sku_set']); - - if ($this->model->update($data, ['id' => $id])) - return json(['code' => '0', 'message' => '保存成功']); - else return json(['code' => '400', 'message' => '保存失败']); - } - - /** - * @return void - * 删除模板 - */ - public function delTemplate($id) - { - if (!intval($id)) { - return json(['code' => '400', 'message' => '模板ID错误']); - } - if ($this->model->delete(['id' => $id])) - return json(['code' => '0', 'message' => '删除成功']); - else return json(['code' => '400', 'message' => '删除失败']); - } -} \ No newline at end of file diff --git a/addon/ali1688/shop/controller/Auth.php b/addon/ali1688/shop/controller/Auth.php deleted file mode 100644 index aa23aad..0000000 --- a/addon/ali1688/shop/controller/Auth.php +++ /dev/null @@ -1,15 +0,0 @@ -site_id); - $token = $cloudApi->getAccessToken($code); - $this->assign('desc', '授权成功'); - $this->assign('img', 'success'); - return $this->fetch('success/success'); - } -} \ No newline at end of file diff --git a/addon/ali1688/shop/controller/Config.php b/addon/ali1688/shop/controller/Config.php deleted file mode 100644 index 0212690..0000000 --- a/addon/ali1688/shop/controller/Config.php +++ /dev/null @@ -1,54 +0,0 @@ -site_id); - $info = $config->getConfig($this->site_id)['data']['value']; - if (request()->isAjax()) { - $isAutoBuyOrder = input('isAutoBuyOrder', 0); - $info['isAutoBuyOrder'] = $isAutoBuyOrder; - $res = $config->setConfig($info, $this->site_id); - return $res; - } - $authorization_url = $CloudApi->getAuthorization_codeurl(request()->domain() . request()->url()); - $openPayinfo['isbuyapp'] = false; - $openPayinfo['ispayopen'] = false; - $openPayinfo['signUrl'] = 'https://tradeconfig.1688.com/foundation/withhold_manage.htm'; - $status = 1; - if ($CloudApi->access_token) { - $openPayinfo =array_merge($openPayinfo, $CloudApi->getTradeIsopenProtocolPay()); -// $getAppBuyInfo = $CloudApi->getAppBuyInfo(); - if ($openPayinfo['ispayopen'] == true) { - $status = 2; - } -// if ($getAppBuyInfo['isbuyapp'] == true) { -// $openPayinfo['isbuyapp'] = true; -// } - } - $this->assign('isAuthorization', $CloudApi->access_token); - $this->assign('openPayinfo', $openPayinfo); - $this->assign('authorization_url', $authorization_url); - $this->assign('info', $info); - $this->assign('site_id', $this->site_id); - $this->assign('checkres', [ - 'code' => 0, - 'data' => [ - 'status' => $status - ]] - ); - $this->forthMenu(); - return $this->fetch("config/basics"); - } - - - public function template() - { - return $this->fetch("config/template"); - } -} diff --git a/addon/ali1688/shop/controller/Goods.php b/addon/ali1688/shop/controller/Goods.php deleted file mode 100644 index 63f7718..0000000 --- a/addon/ali1688/shop/controller/Goods.php +++ /dev/null @@ -1,463 +0,0 @@ -goodsModel = new GoodsModel($this->site_id); - $this->Choice = new Choice($this->site_id); - } - - /** - * 查看已入库商品 - * @return mixed - */ - public function lists() - { - if (request()->isAjax()) { - // 参数获取 - $start_time = input('start_time', ''); - $end_time = input('end_time', ''); - $search = input('goods_name', ''); - if ($start_time && $end_time) { - $condition[] = ['w.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]]; - } elseif (!$start_time && $end_time) { - $condition[] = ['w.create_time', '<=', date_to_time($end_time)]; - - } elseif ($start_time && !$end_time) { - $condition[] = ['w.create_time', '>=', date_to_time($start_time)]; - } - //筛选商品名称 - if (!empty($search)) { - $condition[] = ['w.goods_name', 'like', '%' . $search . '%']; - } - $status = input('goods_state', ''); - if (!empty($status)) { - $condition[] = ['w.goods_state', '=', $status]; - } - $condition[] = ['w.site_id', '=', $this->site_id]; - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - return $this->goodsModel->getGoodsList($condition, $page, $page_size); - } else { - $this->forthMenu(); - return $this->fetch("goods/lists"); - } - } - - /** - * @return void - * 选品入库 - */ - public function servicegoods() - { - $search['site_id'] = $this->site_id; - $template_list = (new TemplateModel($this->site_id))->getTemplateList($search); - $CloudApi = new CloudApi($this->site_id); - $category = $CloudApi->getAlibabaCategory(); - $ProductFilter = $CloudApi->getAlibabaProductFilter(); - if ($ProductFilter) { - foreach ($ProductFilter as $key => $value) { - if (in_array($value['key'], ['dyCiphertext', 'ksCiphertext', 'jxhy'])) { - unset($ProductFilter[$key]); - } - } - } - $this->assign('ProductFilter', $ProductFilter); - $this->assign('category_list', $category); - $this->assign('template_list', $template_list['data']['list']); - return $this->fetch('goods/servicegoods'); - } - - /** - * @return void - * 选品入库 - */ - public function putIn() - { - if (request()->isAjax()) { - $category_id = input("category_id", 0);// 分类id - $productID = input("productID");// 分类id - $category_json = json_encode($category_id);//分类字符串 - $category_id = ',' . implode(',', $category_id) . ','; - $goods_id = input("goods_id", 0);// 商品id - $data = [ - 'goods_id' => $goods_id,// 商品id - 'goods_name' => input("goods_name", ""),// 商品名称, - 'goods_attr_class' => input("goods_attr_class", ""),// 商品类型id, - 'goods_attr_name' => input("goods_attr_name", ""),// 商品类型名称, - 'is_limit' => input("is_limit", "0"),// 商品是否限购, - 'limit_type' => input("limit_type", "1"),// 商品限购类型, - 'site_id' => $this->site_id, - 'category_id' => $category_id, - 'category_json' => $category_json, - 'goods_image' => input("goods_image", ""),// 商品主图路径 - 'goods_content' => input("goods_content", ""),// 商品详情 - 'goods_state' => input("goods_state", ""),// 商品状态(1.正常0下架) - 'price' => input("price", 0),// 商品价格(取第一个sku) - 'market_price' => input("market_price", 0),// 市场价格(取第一个sku) - 'cost_price' => input("cost_price", 0),// 成本价(取第一个sku) - 'sku_no' => input("sku_no", ""),// 商品sku编码 - 'weight' => input("weight", ""),// 重量 - 'volume' => input("volume", ""),// 体积 - 'goods_stock' => input("goods_stock", 0),// 商品库存(总和) - 'goods_stock_alarm' => input("goods_stock_alarm", 0),// 库存预警 - 'is_free_shipping' => input("is_free_shipping", 1),// 是否免邮 - 'shipping_template' => input("shipping_template", 0),// 指定运费模板 - 'goods_spec_format' => input("goods_spec_format", ""),// 商品规格格式 - 'goods_attr_format' => input("goods_attr_format", ""),// 商品参数格式 - 'introduction' => input("introduction", ""),// 促销语 - 'keywords' => input("keywords", ""),// 关键词 - 'unit' => input("unit", ""),// 单位 - 'sort' => input("sort", 0),// 排序, - 'video_url' => input("video_url", ""),// 视频 - 'goods_sku_data' => input("goods_sku_data", ""),// SKU商品数据 - 'goods_service_ids' => input("goods_service_ids", ''),// 商品服务id集合 - 'label_id' => input("label_id", ''),// 商品分组id - 'brand_id' => input("brand_id", 0),//品牌id - 'virtual_sale' => input("virtual_sale", 0),// 虚拟销量 - 'max_buy' => input("max_buy", 0),// 限购 - 'min_buy' => input("min_buy", 0),// 起售 - 'recommend_way' => input('recommend_way', 0), // 推荐方式,1:新品,2:精品,3;推荐 - 'timer_on' => strtotime(input('timer_on', 0)),//定时上架 - 'timer_off' => strtotime(input('timer_off', 0)),//定时下架 - 'spec_type_status' => input('spec_type_status', 0), - 'is_consume_discount' => input('is_consume_discount', 0),//是否参与会员折扣 - 'qr_id' => input('qr_id', 0),//社群二维码id - 'sale_show' => input('sale_show', 0),// - 'stock_show' => input('stock_show', 0),// - 'market_price_show' => input('market_price_show', 0),// - 'barrage_show' => input('barrage_show', 0),// - 'template_id' => input('template_id', 0),//商品海报id - 'form_id' => input('form_id', 0), - 'support_trade_type' => input('support_trade_type', ''), - 'sale_channel' => input('sale_channel', 'all'), - 'sale_store' => input('sale_store', 'all'), - 'is_unify_pirce' => input('is_unify_pirce', '1'), - 'is_zmxx' => input('is_zmxx', 0), - 'cat_id' => input('cat_id', ''), - ]; - if ($goods_id) { - $data['site_id'] = $this->site_id; - $goods_image = explode(',', $data['goods_image']); - $goods_sku_data = json_decode($data['goods_sku_data'], true); - $sku_image = array_column($goods_sku_data, 'sku_image'); - $goods_images = array_unique(array_merge($goods_image, $sku_image)); - $this->goodsModel->GooodsImgCheck($data['site_id'], $goods_images);//验证图片上传 - $res = (new \app\model\goods\Goods())->editGoods($data); - return $res; - } else { - $template_id = input('template_id', 0); - return $this->goodsModel->addGoods($data, $this->site_id, $productID, $template_id); - } - } else { - $data = request()->all(); - $data_list = $this->Choice->productInfoGet($data['itemId']); - if (!$data_list['result']['success']) { - return $this->error($data_list['result']['message'], ''); - } - $aliGoodsInfo = $data_list['result']['result'][0]['productInfo']; - if ($aliGoodsInfo['bizType'] != 1) return $this->error('', '暂不支持非商品请选择其他商品'); - // $freightTemplate = $aliGoodsInfo['shippingInfo']; - // //运费模板 - // if(isset($freightTemplate['freightTemplateID']) && ($freightTemplate['freightTemplateID'] != 0 && $freightTemplate['freightTemplateID'] != 1)){ - // $freight_detail = $this->Choice->productFreightTemplate($freightTemplate['freightTemplateID']); - // } - $price_template = input('template_id', 0); - $saleType = input('saleType', 'normal'); - $sku_url = $this->goodsModel->getDefaultSkuImage(); - $goods_info = $this->goodsModel->generateGoodsInfo($aliGoodsInfo, $price_template, $saleType); - if ($goods_info['goods_id']) { - $editGoodsInfo = event('editGoodsInfo', ['goods_id' => $goods_info['goods_id'], 'site_id' => $this->site_id]); - if ($editGoodsInfo) { - foreach ($editGoodsInfo as $item) { - if ($item['apptype'] == 'aliapp') { - $this->assign("alipay_category_id", $item['category_id'] ?? ''); - } - } - } - } - $search['site_id'] = $this->site_id; - $template_list = (new TemplateModel($this->site_id))->getTemplateList($search); - $this->assign('categoryName', $aliGoodsInfo['categoryName']); - $this->assign('goods_id', $goods_info['goods_id']); - $this->assign('productID', $aliGoodsInfo['productID']); - $this->assign('template_id', $price_template); - $this->assign('goods_info', $goods_info); - $this->assign('sku_url', $sku_url); - $this->assign('template_list', $template_list['data']['list']); - // $this->assign('bizType', ['1' => '商品', '2' => '加工', '3' => '代理', '4' => '合作', '5' => '商务服务']); - // $productType = ['wholesale' => '在线批发商品', 'sourcing' => '询盘商品']; - // $this->assign('productType', $productType); - //获取一级商品分类 - $goods_category_model = new GoodsCategoryModel(); - $condition = [ - ['pid', '=', 0], - ['site_id', '=', $this->site_id] - ]; - $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')['data']; - $this->assign("goods_category_list", $goods_category_list); - - //获取运费模板 - $express_template_model = new ExpressTemplateModel(); - $express_template_list = $express_template_model->getExpressTemplateList([['site_id', "=", $this->site_id]], 'template_id,template_name', 'is_default desc')['data']; - - if (empty($express_template_list)) { - return $this->error("请设置运费模板"); - } - - $this->assign("express_template_list", $express_template_list); - - //获取商品类型 - $goods_attr_model = new GoodsAttributeModel(); - $attr_class_list = $goods_attr_model->getAttrClassList([['site_id', '=', $this->site_id]], 'class_id,class_name')['data']; - $this->assign("attr_class_list", $attr_class_list); - - // 商品服务 - $goods_service_model = new GoodsServiceModel(); - $service_list = $goods_service_model->getServiceList([['site_id', '=', $this->site_id]], 'id,service_name,icon')['data']; - $this->assign("service_list", $service_list); - - // 商品分组 - $goods_label_model = new GoodsLabelModel(); - $label_list = $goods_label_model->getLabelList([['site_id', '=', $this->site_id]], 'id,label_name', 'sort asc')['data']; - $this->assign("label_list", $label_list); - - //商品默认排序值 - $config_model = new ConfigModel(); - $sort_config = $config_model->getGoodsSort($this->site_id, $this->app_module); - $sort_config = $sort_config['data']['value']; - $this->assign("sort_config", $sort_config); - - //获取品牌 - $goods_brand_model = new GoodsBrandModel(); - $brand_list = $goods_brand_model->getBrandList([['site_id', '=', $this->site_id]], "brand_id, brand_name")['data']; - $this->assign("brand_list", $brand_list); - - //获取商品海报 - $poster_template_model = new PosterTemplateModel(); - $poster_list = $poster_template_model->getPosterTemplateList([['site_id', '=', $this->site_id], ['template_status', '=', 1]], 'template_id,poster_name,site_id'); - $this->assign('poster_list', $poster_list['data']); - - $this->assign('virtualcard_exit', addon_is_exit('virtualcard', $this->site_id)); - //获取社群二维码 - $goods_community_model = new GoodsCommunityQrCode(); - $goods_community_qr_list = $goods_community_model->getQrList([['site_id', '=', $this->site_id], ['qr_state', '=', 1]], 'qr_id,qr_name,site_id'); - $this->assign('goods_community_qr_list', $goods_community_qr_list['data']); - $form_is_exit = addon_is_exit('form', $this->site_id); - if ($form_is_exit) { - $form_list = (new Form())->getFormList([['site_id', '=', $this->site_id], ['form_type', '=', 'goods'], ['is_use', '=', 1]], 'id desc', 'id, form_name')['data']; - $this->assign('form_list', $form_list); - } - $this->assign('form_is_exit', $form_is_exit); - $express_type = (new ExpressConfig())->getEnabledExpressType($this->site_id); - $this->assign('express_type', $express_type); - $this->assign('all_goodsclass', event('GoodsClass')); - $this->assign('goods_class', (new \app\model\goods\Goods())->getGoodsClass()); - $this->assign('store_is_exit', addon_is_exit('store', $this->site_id)); - $is_install_supply = addon_is_exit("supply"); - if ($is_install_supply) { - $supplier_model = new SupplierModel(); - $supplier_list = $supplier_model->getSupplyList([['supplier_site_id', '=', $this->site_id]], 'supplier_id,title', 'supplier_id desc')['data']; - $this->assign("supplier_list", $supplier_list); - } - $this->assign("is_install_supply", $is_install_supply); - $config = new \addon\aliapp\model\Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $is_alipay_goods = 0; - if ($config_info) { - $is_alipay_goods = 1; - } - - $this->assign("is_alipay_goods", $is_alipay_goods); - return $this->fetch('goods/edit_goods'); - } - } - - /** - * @return void - * 批量入库 - */ - public function putIns() - { - if (request()->isAjax()) { - $category_id = input("category_id", 0);// 分类id - $goods_id = input("item_id", 0);// 商品id - $category_json = json_encode($category_id);//分类字符串 - $category_id = ',' . implode(',', $category_id) . ','; - $saleType = input("saleType", 'normal'); - if (is_array($goods_id) && count($goods_id) > 0) { - $data_list = $this->Choice->productInfoGet($goods_id); - $aliGoodsInfo = $data_list['result']['result']; - $price_template = input('template_id', 0); - $success = $fail = 0; - $template_id = 0; - if ($saleType != 'normal') { - $template_id = model('express_template')->getValue(['site_id' => $this->site_id, 'is_default' => 1], 'template_id'); - if (empty($template_id)) return $this->error('请先设置默认运费模板'); - } - foreach ($aliGoodsInfo as $key => $val) { - if ($val['productInfo']['bizType'] == 1) { - $goods_info = $this->goodsModel->generateGoodsInfo($val['productInfo'], $price_template, $saleType); - $data = [ - // 商品id - 'goods_name' => $goods_info['goods_name'], - // 商品名称, - 'goods_attr_class' => input("goods_attr_class", ""), - // 商品类型id, - 'goods_attr_name' => input("goods_attr_name", ""), - // 商品类型名称, - 'is_limit' => input("is_limit", "0"), - // 商品是否限购, - 'limit_type' => input("limit_type", "1"), - // 商品限购类型, - 'site_id' => $this->site_id, - 'category_id' => $category_id, - 'category_json' => $category_json, - 'goods_image' => $goods_info['goods_image'], - // 商品主图路径 - 'goods_content' => $goods_info['goods_content'], - // 商品详情 - 'goods_state' => 0, - // 商品状态(1.正常0下架) - 'price' => $goods_info['sku_list'][0]['price'], - // 商品价格(取第一个sku) - 'market_price' => $goods_info['sku_list'][0]['market_price'], - // 市场价格(取第一个sku) - 'cost_price' => $goods_info['sku_list'][0]['cost_price'], - // 成本价(取第一个sku) - 'sku_no' => $goods_info['sku_list'][0]['sku_no'], - // 商品sku编码 - 'weight' => $goods_info['sku_list'][0]['weight'], - // 重量 - 'volume' => $goods_info['sku_list'][0]['volume'], - // 体积 - 'goods_stock' => array_sum(array_column($goods_info['sku_list'], 'stock')), - // 商品库存(总和) - 'goods_stock_alarm' => input("goods_stock_alarm", 0), - // 库存预警 - 'is_free_shipping' => $goods_info['is_free_shipping'],//input("is_free_shipping",1), - - 'shipping_template' => $template_id,//运费模版 // 是否免邮 - - // 指定运费模板 - 'goods_spec_format' => $goods_info['goods_spec_format'], - // 商品规格格式 - 'goods_attr_format' => $goods_info['goods_attr_format'], - // 商品参数格式 - 'introduction' => $goods_info['introduction'], - // 促销语 - 'keywords' => $goods_info['keywords'], - // 关键词 - 'unit' => $goods_info['unit'], - // 单位 - 'sort' => $goods_info['sort'], - // 排序, - 'video_url' => $goods_info['video_url'], - // 视频 - 'goods_sku_data' => $goods_info['goods_sku_data'], - // SKU商品数据 - 'goods_service_ids' => input("goods_service_ids", ''), - // 商品服务id集合 - 'label_id' => input("label_id", ''), - // 商品分组id - 'brand_id' => input("brand_id", 0), - //品牌id - 'virtual_sale' => $goods_info['virtual_sale'], - // 虚拟销量 - 'max_buy' => $goods_info['max_buy'], - // 限购 - 'min_buy' => $goods_info['min_buy'], - // 起售 - 'recommend_way' => input('recommend_way', 0), - // 推荐方式,1:新品,2:精品,3;推荐 - 'timer_on' => strtotime(input('timer_on', 0)), - //定时上架 - 'timer_off' => strtotime(input('timer_off', 0)), - //定时下架 - 'spec_type_status' => empty($goods_info['spec_type_status']) ? 0 : 1, - 'is_consume_discount' => $goods_info['is_consume_discount'], - //是否参与会员折扣 - 'qr_id' => $goods_info['qr_id'], - //社群二维码id - 'sale_show' => $goods_info['sale_show'], - 'stock_show' => $goods_info['stock_show'], - 'market_price_show' => $goods_info['market_price_show'], - 'barrage_show' => $goods_info['barrage_show'], - 'template_id' => 0, - //商品海报id - 'form_id' => 0, - 'support_trade_type' => $goods_info['support_trade_type'], - 'sale_channel' => input('sale_channel', 'all'), - 'sale_store' => input('sale_store', 'all'), - 'is_unify_pirce' => $goods_info['is_unify_pirce'], - 'is_zmxx' => $goods_info['is_zmxx'], - 'cat_id' => '', - ]; - $res = $this->goodsModel->addGoods($data, $this->site_id, $val['productInfo']['productID'], $price_template); - if ($res['code'] === 0) { - $success++; - } else { - $fail++; - } - } else { - $fail++; - } - } - $msg = '入库成功' . $success . '件商品'; - return ['code' => 0, 'data' => '入库成功', 'message' => $fail > 0 ? $msg . ',入库失败' . $fail . '件' : $msg]; - } - } else { - $data = request()->all(); - //获取一级商品分类 - $goods_category_model = new GoodsCategoryModel(); - $condition = [ - ['pid', '=', 0], - ['site_id', '=', $this->site_id] - ]; - $template_id = input('template_id', 0); - $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')['data']; - $this->assign("goods_category_list", $goods_category_list); - $this->assign("item_id", $data['itemId']); - $this->assign("template_id", $template_id);//单独选择模板 - $search['site_id'] = $this->site_id; - $template_list = (new TemplateModel($this->site_id))->getTemplateList($search); - $this->assign('template_list', $template_list['data']['list']); - return $this->fetch('goods/putins'); - } - } - - /** - * @return void - * 从1688获取入库商品 - */ - public function getGoodsList() - { - $param = request()->all(); - return $this->Choice->productlist($param); - } -} diff --git a/addon/ali1688/shop/controller/Order.php b/addon/ali1688/shop/controller/Order.php deleted file mode 100644 index 88d6f74..0000000 --- a/addon/ali1688/shop/controller/Order.php +++ /dev/null @@ -1,116 +0,0 @@ -isAjax()) { - // 参数获取 - $search = request()->all(); - $search['site_id'] = $this->site_id; - return (new OrderModel())->getOrderList($search); - } else { - $this->forthMenu(); - return $this->fetch("order/lists"); - } - } - - - /*** - * 获取子菜单 - * @return array|mixed - */ - public function seeSubOrder() - { - $order_id = input('order_id', 0); - if (request()->isAjax()) { - $search = request()->all(); - $res = (new orderModel())->getSubOrder($this->site_id, $order_id,$search); - return $res; - } - return $this->fetch('order/sub_list', ['order_id' => $order_id]); - } - - /** - * Common: 请求重新下单 - * Author: wu-hui - * Time: 2023/09/05 11:18 - * @return array - */ - public function reorder() - { - // 参数获取 - $orderId = input('order_id', 0); - if ((int)$orderId <= 0) return error(-1, '订单不存在!'); - // 获取订单信息 - $orderInfo = model('order')->getInfo([ - ['order_id', '=', $orderId] - ]); - if($orderInfo['pay_status']!=1) return error(-1, '买家未付款无需下单!'); - $res = (new orderModel())->orderCreateRequest($orderId); - return $res; - } - - - /** - * Common: 子订单 - 单个商品申请退款 - * Author: wu-hui - * Time: 2023/09/06 16:12 - * @return array - */ - public function subOrderRefund() - { - $info = input('info', []); - $info['site_id'] = $this->site_id; - (new orderModel())->refundOrder($info); - return success(0, '退款申请成功!'); - } - - - /*** - * 发起免密支付 - * @return void - */ - public function buyPay() - { - $id = input('order_id', 0); - if (request()->isAjax()) { - $res = (new orderModel())->noPasswordPay($this->site_id, $id); - return $res; - } - } - - /*** - * 在线支付 - * @return array|void|null - */ - public function onlinePay() - { - $id = input('order_id', 0); - if (request()->isAjax()) { - $res = (new orderModel())->onlinePay($this->site_id, $id); - return $res; - } - } - /*** - * 取消订单 - * @return array|void|null - */ - public function cancelOrder() - { - if (request()->isAjax()) { - $data = request()->all(); - $res = (new orderModel())->cancelOrder($this->site_id, $data['order_id'], $data['cancelReason']); - return $res; - } - } -} diff --git a/addon/ali1688/shop/controller/Template.php b/addon/ali1688/shop/controller/Template.php deleted file mode 100644 index da50dce..0000000 --- a/addon/ali1688/shop/controller/Template.php +++ /dev/null @@ -1,91 +0,0 @@ -templateModel = new TemplateModel($this->site_id); - } - - public function lists() - { - if (request()->isAjax()) { - // 参数获取 - $search = request()->all(); - $search['site_id'] = $this->site_id; - return $this->templateModel->getTemplateList($search); - } - $this->forthMenu(); - return $this->fetch("template/lists"); - } - - public function add() - { - if (request()->isAjax()) { - // 参数获取 - $data = request()->all(); - $data['site_id'] = $this->site_id; - $data['create_time'] = time(); - return $this->templateModel->addTemplate($data); - } - $this->get_list(); - return $this->fetch("template/add"); - } - - public function get_list() - { - //获取一级商品分类 - $goods_category_model = new GoodsCategoryModel(); - $condition = [ - ['pid', '=', 0], - ['site_id', '=', $this->site_id] - ]; - $goods_category_list = $goods_category_model->getCategoryList($condition, 'category_id,category_name,level,commission_rate')['data']; - $this->assign("goods_category_list", $goods_category_list); - $express_template_model = new ExpressTemplate(); - $condition = array( - ['site_id', "=", $this->site_id], - ); - $express_template_list = $express_template_model->getExpressTemplatePageList($condition); - $this->assign("express_template_list", $express_template_list['data']['list']); - $this->assign('goods_class', array_column(event('GoodsClass'), null, 'goods_class')); - } - - public function edit() - { - $data = request()->all(); - if (!isset($data['id']) && !intval($data['id'])) { - return $this->error('模板ID错误'); - } - if (request()->isAjax()) { - $data['update_time'] = time(); - return $this->templateModel->editTemplate($data); - } - $data = $this->templateModel->templateInfo($data['id']); - $this->assign('data', $data); - $this->get_list(); - return $this->fetch("template/edit"); - } - - public function del() - { - $data = request()->all(); - if (!isset($data['id']) && !intval($data['id'])) { - return $this->error('模板ID错误'); - } - if (request()->isAjax()) { - return $this->templateModel->delTemplate($data['id']); - } - } -} \ No newline at end of file diff --git a/addon/ali1688/shop/view/config/basics.html b/addon/ali1688/shop/view/config/basics.html deleted file mode 100644 index 7c78943..0000000 --- a/addon/ali1688/shop/view/config/basics.html +++ /dev/null @@ -1,318 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
1688精选代发
- -
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/config/template.html b/addon/ali1688/shop/view/config/template.html deleted file mode 100644 index cfe5bca..0000000 --- a/addon/ali1688/shop/view/config/template.html +++ /dev/null @@ -1,275 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
1688精选代发
- -
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/goods/edit.html b/addon/ali1688/shop/view/goods/edit.html deleted file mode 100644 index 99b856a..0000000 --- a/addon/ali1688/shop/view/goods/edit.html +++ /dev/null @@ -1,353 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="body"} - -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
- -
-
-
- - - - - - - - - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/goods/edit_goods.html b/addon/ali1688/shop/view/goods/edit_goods.html deleted file mode 100644 index d364771..0000000 --- a/addon/ali1688/shop/view/goods/edit_goods.html +++ /dev/null @@ -1,1216 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - - - -{/block} -{block name="body"} -
-
- -
- -
-
-
- 基础信息 -
- -
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
-
第一张图片将作为商品主图,支持同时上传多张图片,多张图片之间可随意调整位置;
-
支持jpg、gif、png格式上传或从图片空间中选择,建议使用尺寸800x800像素以上、大小不超过1M的正方形图片;
-
上传后的图片将会自动保存在图片空间的默认分类中,最多上传10张(至少1张)
-
- -
- -
-
- -
-
- 删除 - 上传视频 -
-
-
- -
- -
- -
-
-
注意事项:
-
    -
  • 1、视频支持手动输入外链视频地址或者上传本地视频文件
  • -
  • 2、必须上传.mp4视频格式
  • -
  • 3、视频文件大小不能超过500MB
  • -
-
-
-
- -
- - -
-
-
- -
- -
-
- {notempty name="$service_list"} -
- -
- {foreach name="$service_list" item="vo"} - -1}checked{/if}> - {/foreach} -
-
- {/notempty} -
- -
-
-
-
- {if $goods_info['goods_category']} - {foreach $goods_info['goods_category'] as $cate_k => $cate_v} -
-
- - -
- 刷新  - 添加分类 - {if $cate_k != 0} - 删除 - {/if} -
- {/foreach} - {else} -
-
- - -
- 刷新  - 添加分类 -
- {/if} -
- -
-
-
-
商品可以属于多个分类,最多10个
-
- -
- {if $is_alipay_goods} -
- -
- - -
-
选择支付宝分类,商品将自动同步支付宝小程序商品库,首次或无法分类您可以同步分类
-
- {/if} -
- -
- -
- - -
-
支付宝芝麻线上线下,用户先用后付,芝麻先享后付
-
-
- -
- - -
-
- {if $goods_info['goods_state'] == 0} -
- -
- 0} checked {/if}> - -
-
启用定时上架后,到达设定时间,此商品将自动上架。
-
- {if $goods_info['timer_on'] > 0} -
- -
- - -
-
- {else/} -
- -
- - -
-
- {/if} - {/if} -
- -
- 0} checked {/if}> - -
-
启用定时下架后,到达设定时间,此商品将自动下架。
-
- {if $goods_info['timer_off'] > 0} -
- -
- - -
-
- {else/} - - {/if} - - {if addon_is_exit('cashier') == 1} -
- -
- - - -
-
- {/if} - - {if $store_is_exit} -
- -
- - -
-
- -
- -
- -
- - - - - - - - - - - - - {if isset($store_list) && !empty($store_list)} - {foreach name="$store_list" item="vo"} - - - - - - {/foreach} - {/if} - -
门店名称门店地址操作
{$vo.store_name}{$vo.full_address}{$vo.address}删除
-
-
-
- -
- -
- - -
-
价格设置之后门店不能修改价格,门店按照平台设置的价格售卖
-
- {/if} -
-
- - -
-
- 社群信息 -
-
-
- -
- -
-
-
您可以添加多个社群模版
-
-
- - -
-
- 配送信息 -
-
-
- -
- {notempty name="$express_type"} - {foreach name="$express_type" item="vo" key="key"} - - {/foreach} - {else/} - 未配置配送方式,请先配置配送方式 - {/notempty} -
- {notempty name="$express_type"}{/notempty} -
- -
-
- -
- - -
-
- -
- -
- -
-
- 刷新 - 新建 -
-
-
-
-
- -
- - -
- -
- -
- - -
-
- - -
- -
- -
- -
-
-
商品没有相关优惠活动的实际卖价
-
- -
- -
- -
-
-
商品没有优惠活动显示的划线价格,如果商品有折扣等优惠活动划线价显示销售价
-
- -
- -
- -
-
-
成本价将不会对前台会员展示,用于商家统计使用
-
- -
- -
- -
kg
-
-
- -
- -
- -
m3
-
-
- -
- -
- -
-
- -
- - -
- - -
- -
- -
- -
-
- -
- -
- 副标题 - 销售价 - 划线价 - 成本价 - 库存 - 库存预警 - 重量(kg) - 体积(m³) - 商品编码 - - - -
-
- - -
- {foreach name="$goods_info['sku_list']" item="vo" key="k"} -
- - - - - - - - - - - - - - - -
- {/foreach} -
- - -
- -
-
- -
- -
- -
- -
-
-
- -
- -
- -
-
-
商品库存少于等于预警数量,商品列表库存数量标红显示,0为不预警。
-
- -
- -
- -
-
- -
- -
- -
-
-
该设置不计入商品统计数据
-
- -
- -
- - -
-
启用限购后,购买商品时,会对该商品购买量做限制判断。
-
- -{if $goods_info['is_limit'] == 1} -
- -
- - - -
 件
-
-
单次限购是针对于每次下单不能超过限购数量,长期限购是针对于会员账号购买这个商品的总数不能超过限购数量。
-
-{/if} - -
- -
- -
-
-
起售数量超出商品库存时,买家无法购买该商品
-
- -
- -
-
- 0} checked {/if}> - -
-
-
如果该商品未单独配置过优惠规则,则按照默认会员等级折扣优惠
-
-
- -
-
- -
- - -
-
- - - -
- -
-
- -
- - -
-
商品可以添加自定义商品参数,也可以通过参数模板批量设置商品参数
-
- -
- -
-
- - - - - - - - - - - - - - - - - -
参数名参数 - 排序 -
- -
-
- 设置排序,改变商品规格展示顺序 -
-
-
-
操作
无数据
-
- -
-
- -
-
-
- 高级设置 -
- -
-
- -
- -
-
商品默认排序号为0,数字越大,排序越靠前,数字重复,则最新添加的靠前。
-
- -
- -
- 0} checked {/if}> - -
-
- -
- -
- 0} checked {/if}> - -
-
- -
- -
- 0} checked {/if}> - -
-
- -
- -
- 0} checked {/if}> - -
-
-
- -
- -
-
- - {if $form_is_exit} -
- -
- -
- -
- {/if} -
-
-
-
- - - - - - - -
- - - -
-
- - - - - - - - - - - - - -{/block} -{block name="script"} - - - - - - - - - - - -{/block} diff --git a/addon/ali1688/shop/view/goods/lists.html b/addon/ali1688/shop/view/goods/lists.html deleted file mode 100644 index 71ed428..0000000 --- a/addon/ali1688/shop/view/goods/lists.html +++ /dev/null @@ -1,211 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} - -
-
-
-
-
- -
- -
-
-
-
- - -
-
-
-
-
- 选品广场 -
-
- -
-
- - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/goods/putIn.html b/addon/ali1688/shop/view/goods/putIn.html deleted file mode 100644 index 5b07e09..0000000 --- a/addon/ali1688/shop/view/goods/putIn.html +++ /dev/null @@ -1,191 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="body"} -
- {if $result.success} -
- -
-
-
-
- 基础信息 -
-
-
- -
- -
-
-
- -
-
- {foreach name="$result.result.0.productInfo.image.images" item="vo"} -
-
- -
-
- {/foreach} -
-
-
-
- -
- {$result['result'][0]['productInfo']['categoryName']} -
-
-
- -
- {$result['result'][0]['productInfo']['referencePrice']} - -
-
-
- -
- {$productType[$result['result'][0]['productInfo']['productType']]} -
-
-
- -
- {$bizType[$result['result'][0]['productInfo']['bizType']]} -
-
-
- -
- {$result['result'][0]['productInfo']['qualityLevel']} -
-
-
-
-
-
-
- -
- {$result['result'][0]['productInfo']['saleInfo']['supportOnlineTrade'] == '1' ? '是' : '否'} -
-
-
- -
- {$result['result'][0]['productInfo']['saleInfo']['mixWholeSale'] == '1' ? '是' : '否'} -
-
-
- -
- {$result['result'][0]['productInfo']['saleInfo']['amountOnSale']} -
-
-
- -
- {$result['result'][0]['productInfo']['saleInfo']['unit']} -
-
-
-
- - - - - - - - - - - - - {if isset($result.result.0.productInfo.skuInfos)} - {foreach name="$result.result.0.productInfo.skuInfos" item="vo"} - - - - - - - - - {/foreach} - {/if} - -
sku信息商品码库存零售价基准价specId
- - {$vo.skuCode ?? ''}{$vo.amountOnSale ?? ''}{$vo.retailPrice ?? ''}{$vo.consignPrice ?? ''}{$vo.specId ?? ''}
-
-
-
- - -
- - - -
-
5
-
-
- -
-
- {else} -
- {$result.errorMsg} -
- {/if} -
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/goods/putins.html b/addon/ali1688/shop/view/goods/putins.html deleted file mode 100644 index fa0d453..0000000 --- a/addon/ali1688/shop/view/goods/putins.html +++ /dev/null @@ -1,150 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} -{block name="body"} -
- -
-
-
- 入库设置 -
-
-
- -
-
-
-
-
-
- - -
- 刷新  - 添加分类 -
-
- -
-
-
-
商品可以属于多个分类,最多10个
-
-
- {if count($template_list) > 0 } -
- -
- -
-
- {/if} -
-
- -
- - -
-
-
-

批发售卖模式,采购价部分不包邮,入库请自行设计运费模版

-
-
- {foreach name="$item_id" item="vo"} - - {/foreach} -
-
-
- -
-
-{/block} -{block name="script"} - - - - -{/block} diff --git a/addon/ali1688/shop/view/goods/servicegoods.html b/addon/ali1688/shop/view/goods/servicegoods.html deleted file mode 100644 index a714bf7..0000000 --- a/addon/ali1688/shop/view/goods/servicegoods.html +++ /dev/null @@ -1,335 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
- -
-
-
-
-
- -
- -
-
-
-
- -
- {foreach $ProductFilter as $Filter} - - {/foreach} -
-
- - - - - - - - -
- - -
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
- - - -{/block} -{block name="script"} - -{/block} diff --git a/addon/ali1688/shop/view/goods/warehonsing.html b/addon/ali1688/shop/view/goods/warehonsing.html deleted file mode 100644 index 7aaacf6..0000000 --- a/addon/ali1688/shop/view/goods/warehonsing.html +++ /dev/null @@ -1,355 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="body"} - -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
- -
-
-
- - - - - - - - - - - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/order/lists.html b/addon/ali1688/shop/view/order/lists.html deleted file mode 100644 index a13cbe7..0000000 --- a/addon/ali1688/shop/view/order/lists.html +++ /dev/null @@ -1,364 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="main"} - -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
- -
- - - - -{/block} -{block name="script"} - -{/block} diff --git a/addon/ali1688/shop/view/order/sub_list.html b/addon/ali1688/shop/view/order/sub_list.html deleted file mode 100644 index 88420d1..0000000 --- a/addon/ali1688/shop/view/order/sub_list.html +++ /dev/null @@ -1,170 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="body"} - -
-
-
- - - - -{/block} -{block name="script"} - -{/block} diff --git a/addon/ali1688/shop/view/success/success.html b/addon/ali1688/shop/view/success/success.html deleted file mode 100644 index 8fc6b56..0000000 --- a/addon/ali1688/shop/view/success/success.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - 授权通知 - - - - -
-
-
{$desc}
-
-
- -
-
-
- - - - - \ No newline at end of file diff --git a/addon/ali1688/shop/view/template/add.html b/addon/ali1688/shop/view/template/add.html deleted file mode 100644 index 27d30d5..0000000 --- a/addon/ali1688/shop/view/template/add.html +++ /dev/null @@ -1,217 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="main"} -
-
- -
- -
-
例如:加价20%模板
-
- -
- -
-
- 价格 = 1688价格 * -
-
- -
-
+
-
- -
-
-
提示:百分百和递增数可以不填或只填一个;优先按百分百增长
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
-
替换为
-
- -
- -
-
-
- -
-
-
- -
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
- -
-
替换为
-
- -
- -
-
-
- -
-
-
-
- - - -
-
-{/block} -{block name="script"} - - - - - - - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/template/edit.html b/addon/ali1688/shop/view/template/edit.html deleted file mode 100644 index af84af4..0000000 --- a/addon/ali1688/shop/view/template/edit.html +++ /dev/null @@ -1,233 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="main"} -
- -
- -
- -
-
例如:加价20%模板
-
- -
- -
-
- 价格 = 1688进价 * -
-
- -
-
-
- -
-
-
提示:百分百和递增数可以不填或只填一个;优先按百分百增长
-
- - -
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - {if isset($data['title_set']['replace_keywords']['before'])} - {foreach $data['title_set']['replace_keywords']['before'] as $key=>$val} - {if $val} -
-
- -
-
替换为
-
- -
- -
- {/if} - {/foreach} - {/if} -
-
- -
-
-
-
- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- - - {if isset($data['sku_set']['replace_keywords']['before'])} - {foreach $data['sku_set']['replace_keywords']['before'] as $key=>$val} - {if $val} -
-
- -
-
替换为
-
- -
- -
- - {/if} - {/foreach} - {/if} -
-
- -
-
-
-
- - - -
-
-{/block} -{block name="script"} - - - - - - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/template/lists.html b/addon/ali1688/shop/view/template/lists.html deleted file mode 100644 index f1a5f4b..0000000 --- a/addon/ali1688/shop/view/template/lists.html +++ /dev/null @@ -1,188 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} - -
-
-
-
-
- -
- -
- -
-
- -
-
-
- -
- - -{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/ali1688/shop/view/template/template.html b/addon/ali1688/shop/view/template/template.html deleted file mode 100644 index 771cdc5..0000000 --- a/addon/ali1688/shop/view/template/template.html +++ /dev/null @@ -1,278 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
1688精选代发
- -
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/api/controller/Aliapp.php b/addon/aliapp/api/controller/Aliapp.php deleted file mode 100644 index 61583cf..0000000 --- a/addon/aliapp/api/controller/Aliapp.php +++ /dev/null @@ -1,25 +0,0 @@ -site_id); - $baseInfo = $aliPayAppletModel->loginBaseInfo($this->params['code']); - return $this->response($baseInfo); - } catch (Exception $e) { - return $this->response([]); - } - } - - //用户订阅消息 - public function messagetmplids() - { - return $this->response($this->success()); - } -} \ No newline at end of file diff --git a/addon/aliapp/api/controller/AliappMemberCard.php b/addon/aliapp/api/controller/AliappMemberCard.php deleted file mode 100644 index cf414f5..0000000 --- a/addon/aliapp/api/controller/AliappMemberCard.php +++ /dev/null @@ -1,217 +0,0 @@ -aop = new AopClient(); - $this->aop->alipayrsaPublicKey = $config_info['public_key'] ?? ""; - $this->aop->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; - $this->aop->appId = $config_info["appid"] ?? ""; - $this->aop->rsaPrivateKey = $config_info['private_key'] ?? ""; - $this->aop->alipaySdkVersion = "alipay-sdk-php-20200415"; - $this->aop->apiVersion = '1.0'; - $this->aop->signType = 'RSA2'; - $this->aop->postCharset = 'UTF-8'; - $this->aop->format = 'json'; - } - - public function userOpencardGet() - { - $param = request()->param(); -// $param = json_decode('{"sign":"n1x8rBXsU0Hb\/kX5GT\/OMxKh5Sr3Zslz0a8njra+cU6DzEaeniquoNYCKyY3nz3WZ5TfQsuXQq3ukvoh9SOfXyRKmpbb5nnMmhyqI3d7E\/n7o7\/W+cJAeBIgcpUOlj1BZ0sp5e84IWa7XIaYGCTODa8mRGNJAuVM4JIYt4eQP5ExrcFMY4fzE\/SUicDeOAnA29upUKJoaVQNZ1orpLYe1TzeVHEQImoBG0crt8MeCepTFmNlXJMAeD1AjPsbSUpY8rlj4canR+dkzKzh4uKD+kwxSzfLcOM9nf9bZcNiW2bURJ6ZICzEA7Kuskh1OpJ3GwQ8P1ex5vyrtA1+HM7IoA==","method":"spi.alipay.user.opencard.get","charset":"UTF-8","version":"1.0","utc_timestamp":"1694872947","sign_type":"RSA2","out_serial_no":"2088002141785385|20230916|20230916220137444","biz_card_no":"00000000000000000138","template_id":"20230916000000004853317000300387","user_id":"2088002141785385","user_info":"[{\"OPEN_FORM_FIELD_NAME\":\"胡治金\"},{\"OPEN_FORM_FIELD_GENDER\":\"男\"},{\"OPEN_FORM_FIELD_MOBILE\":\"18982255122\"},{\"OPEN_FORM_FIELD_BIRTHDAY\":\"04-02\"}]"}', true); - Log::write('支付宝回调通知-会员卡-userOpencardGet:' . json_encode($param, JSON_UNESCAPED_UNICODE)); - $rsaCheck = $this->rsaCheck($param); - if (!$rsaCheck) { - $res = [ - 'response' => [ - 'code' => '40004', - 'msg' => 'Business Failed', - ], - ]; - return json_encode($res, JSON_UNESCAPED_UNICODE); - } - $time = time(); - $timestr = date("Y-m-d H:i:s", $time); - $template = model('member_level')->getInfo([['template_id', '=', $param['template_id']]]); - $member = model('member')->getInfo([ - ['site_id', '=', $template['site_id']], - ['ali_openid', '=', $param['user_id']] - ]); - $realname = ''; - $sex = 0; - $mobile = ''; - $birthday = ''; - $user_info = json_decode($param['user_info'], TRUE); - foreach ($user_info as $itemArray) { - foreach ($itemArray as $key => $item) { - switch ($key) { - case 'OPEN_FORM_FIELD_NAME': - $realname = $item; - break; - case 'OPEN_FORM_FIELD_GENDER': - switch ($item) { - case '男': - $sex = 1; - break; - case '女': - $sex = 2; - break; - } - break; - case 'OPEN_FORM_FIELD_MOBILE': - $mobile = $item; - break; - case 'OPEN_FORM_FIELD_BIRTHDAY': - $birthday = strtotime('1970-' . $item); - break; - } - } - } - $res = [ - 'response' => [ - 'code' => '10000', - 'msg' => 'Success', - 'card_info' => [ - 'biz_card_no' => $param['biz_card_no'], - 'external_card_no' => 10000 + $member['member_id'], - 'open_date' => $timestr, - 'valid_date' => date("Y-m-d H:i:s", $time + 10 * 365 * 24 * 60 * 60), - 'template_id' => $param['template_id'], - 'level' => 'VIP1', - 'point' => $member['point'] + $template['send_point'], - 'balance' => $member['balance'] + $template['send_balance'], - ], - ], - ]; - $upMemberData = [ - 'is_member' => 1, - 'realname' => $realname, - 'sex' => $sex, - 'mobile' => $mobile, - 'birthday' => $birthday, - 'ali_card_no' => $param['biz_card_no'], - ]; - $this->CreateMemberLevel($member, $template, $upMemberData); - return json_encode($res, JSON_UNESCAPED_UNICODE); - } - - - public function CreateMemberLevel($member_info, $level_info, $upMemberData) - { - - $member_account = new MemberAccount(); - model('member_level_order')->startTrans(); - try { - $level_info['period_unit'] = 'year'; - // 如果是首次开卡发放开卡礼包 - $count = model('member_level_records')->getCount([['after_level_id', '=', $level_info['level_id']], ['member_id', '=', $member_info['member_id']]]); - if ($count == 0) { - //赠送红包 - if ($level_info['send_balance'] > 0) { - $member_account->addMemberAccount($member_info['site_id'], $member_info['member_id'], 'balance', $level_info['send_balance'], 'memberlevel', '会员开卡得红包' . $level_info['send_balance'], '会员开卡奖励发放'); - } - //赠送积分 - if ($level_info['send_point'] > 0) { - $member_account->addMemberAccount($member_info['site_id'], $member_info['member_id'], 'point', $level_info['send_point'], 'memberlevel', '会员开卡得积分' . $level_info['send_point'], '会员开卡奖励发放'); - } - //给用户发放优惠券 - if (!empty($level_info['send_coupon'])) { - $coupon_array = explode(',', $level_info['send_coupon']); - $coupon_model = new Coupon(); - $coupon_array = array_map(function ($value) { - return ['coupon_type_id' => $value, 'num' => 1]; - }, $coupon_array); - $coupon_model->giveCoupon($coupon_array, $member_info['site_id'], $member_info['member_id'], 5); - } - } - if ($member_info['member_level'] != $level_info['level_id']) { - if ($level_info['period_unit'] == 'quarter') { - $expire_time = strtotime("+3 month"); - } else { - $expire_time = strtotime("+{1 {$level_info['period_unit']}"); - } - // 添加会员卡变更记录 - $member_level_model = new MemberLevel(); - $member_level_model->addMemberLevelChangeRecord($member_info['member_id'], $member_info['site_id'], $level_info['level_id'], $expire_time, 'buy', $member_info['member_id'], 'member', $member_info['nickname']); - } else { - $old_expire_time = date('Y-m-d', $member_info['level_expire_time']); - if ($level_info['period_unit'] == 'quarter') { - $expire_time = strtotime("{$old_expire_time} +3 month"); - } else { - $expire_time = strtotime("{$old_expire_time} +1} {$level_info['period_unit']}"); - } - $upMemberData['level_expire_time'] = $expire_time; - // 更新会员卡过期时间 - model('member')->update($upMemberData, [['member_id', '=', $member_info['member_id']]]); - $cron = new Cron(); - $cron->deleteCron([['event', '=', 'MemberLevelAutoExpire'], ['relate_id', '=', $member_info['member_id']]]); - $cron->addCron(1, 0, "会员卡自动过期", "MemberLevelAutoExpire", $expire_time, $member_info['member_id']); - } - model('member_level_order')->commit(); - return $this->success(); - } catch (\Exception $e) { - model('member_level_order')->rollback(); - return $this->error('', $e->getMessage()); - } - } - - - - public function testuserOpencardGet() - { - - $param = request()->param(); - Log::write('支付宝回调通知-会员卡-userOpencardGet:' . json_encode($param, JSON_UNESCAPED_UNICODE)); - $rsaCheck = $this->rsaCheck($param); - if (!$rsaCheck) { - $res = [ - 'response' => [ - 'code' => '40004', - 'msg' => 'Business Failed', - ], - ]; - // $res["sign"] = $this->aop->generateSign($res, "RSA2"); - return json_encode($res, JSON_UNESCAPED_UNICODE); - } - $time = time(); - $timestr = date("Y-m-d H:i:s", $time); - $res = [ - 'response' => [ - 'code' => '10000', - 'msg' => 'Success', - 'card_info' => [ - 'biz_card_no' => $param['biz_card_no'], - 'external_card_no' => '000001', - 'open_date' => $timestr, - 'valid_date' => date("Y-m-d H:i:s", $time + 10 * 365 * 24 * 60 * 60), - 'template_id' => $param['template_id'], - 'balance' => '124.89' - ], - ], - ]; - // $res["sign"] = $this->aop->generateSign($res, "RSA2"); - - - return json_encode($res, JSON_UNESCAPED_UNICODE); - } - public function rsaCheck($param) - { - $payModel = new MinCode(); - $res = $payModel->verifySgin($param); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/api/controller/Order.php b/addon/aliapp/api/controller/Order.php deleted file mode 100644 index 3e78ea4..0000000 --- a/addon/aliapp/api/controller/Order.php +++ /dev/null @@ -1,162 +0,0 @@ -'CREATE',//创建 - 1=>'WAIT_PAY',//代支付 - 2=>'CLOSED',//关闭 - 3=>'REFUNDING',//退款中 - 4=>'REFUNDED',//已退款 - 5=>'FINISHED',//已完成 - 6=>'IN_DELIVERY',//已发货配送中 - 7=>'REFUND_PART',//部分退款 - 8=>'RETURN_PART',//部分退货 - 9=>'TO_SEND_GOODS',//待发货 - 10=>'PARTIAL_DELIVERY',//部分发货 - 11=>'SIGNED',//已签收 - 12=>'PAID',//支付完成 - - - 15=>'TO_BE_DELIVERED',//待配送 - 13=>'CENTRE_DELIVERY',//社区团购中心仓配货 - 14=>'GRID_DELIVERY',//网格仓配送 - ]; - function __construct() - { - parent::__construct(); - $config_info = config('alipay.platform'); - // 获取支付宝支付参数(统一支付到平台账户) - $this->aop = new AopClient(); - $this->aop->alipayrsaPublicKey = $config_info['public_key'] ?? ""; - $this->aop->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; - $this->aop->appId = $config_info["appid"] ?? ""; - $this->aop->rsaPrivateKey = $config_info['private_key'] ?? ""; - $this->aop->alipaySdkVersion = "alipay-sdk-php-20200415"; - $this->aop->apiVersion = '1.0'; - $this->aop->signType = 'RSA2'; - $this->aop->postCharset = 'UTF-8'; - $this->aop->format = 'json'; - } - - /*** - * 单个订单查询 - * spi.alipay.merchant.order.realtimeinfo.query - * @return void - */ - public function query() - { - file_put_contents('query.txt', json_encode(input(''))); - $merchant_order_no=input('merchant_order_no',''); - $result=[]; - if($merchant_order_no){ - $order_common_model = new OrderCommonModel(); - $condition=[ - ['out_trade_no','=',$merchant_order_no] - ]; - $orderInfo=$order_common_model->getOrderInfo($condition); - $result=[ - 'merchant_order_status'=>'', - ]; - } - $data = [ - 'code' => 10000, - 'msg' => 'Success', - 'success' => true, - 'result' => [], - 'error_code' => '', - 'error_desc' => '', - ]; - if(empty($result)){ - $data['code']='40004'; - $data['success']=false; - $data['error_code']='BIZ_ERROR'; - $data['error_desc']='未找到当前订单'; - } - $response = [ - 'response' =>$data , - 'sign' => $this->sign($data), - ]; -// return json($response); - } - - - /*** - * 批量订单查询 - * @return void - */ - public function batchquery() - { - file_put_contents('batchquery.txt', json_encode(input(''))); - $data = [ - 'code' => 10000, - 'msg' => 'Success', - 'success' => true, - 'error_code' => '', - 'error_desc' => '', - 'journey_order_list' => [], - ]; - if(empty($result)){ - $data['code']='40004'; - $data['success']=false; - $data['error_code']='BIZ_ERROR'; - $data['error_desc']='未找到当前订单'; - } - $response = [ - 'response' =>$data , - 'sign' => $this->sign($data), - ]; -// return json($response); - } - - /** - * 支付宝 - * 本地生活 - * 查询订单是否可退款 - * @return void - */ - public function refundconfirm() - { - - file_put_contents('refundconfirm.txt', json_encode(input(''))); - } - - - /*** - * 本地生活 - * 三方凭证发放 - * 商家发送核销凭证 - * @return void - */ - public function send() - { - file_put_contents('Minsend.txt', json_encode(input(''))); - } - - - /** - * 小程序商品动态数据查询 - * @return void - */ - public function MinBatchquery() - { - file_put_contents('MinBatchquery.txt', json_encode(input(''))); - } - - - /*** - * 签名 - * @param $response - * @return string|null - */ - private function sign($response = []) - { - ksort($response); - $sign=$this->aop->sign(json_encode($response), "RSA2"); - return $sign; - } -} \ No newline at end of file diff --git a/addon/aliapp/config/diy_view.php b/addon/aliapp/config/diy_view.php deleted file mode 100644 index 752d87a..0000000 --- a/addon/aliapp/config/diy_view.php +++ /dev/null @@ -1,12 +0,0 @@ - [ - 'view' => [ - ], - 'util' => [ - ], - 'link' => [ - ], - - ], -]; \ No newline at end of file diff --git a/addon/aliapp/config/event.php b/addon/aliapp/config/event.php deleted file mode 100644 index c13ef4d..0000000 --- a/addon/aliapp/config/event.php +++ /dev/null @@ -1,74 +0,0 @@ - [], - 'listen' => [ - // 生成获取二维码 - 'Qrcode' => [ - 'addon\aliapp\event\Qrcode' - ], - 'ShowPromotion' => [ - 'addon\aliapp\event\ShowPromotion', - ], - 'DecryptData' => [ - 'addon\aliapp\event\DecryptData', - ], - 'SendMessageTemplate'=>[ //发送模版消息 - 'addon\aliapp\event\SendMessageTemplate' - ], - // 支付宝网关通知 - 'AliAuthNotify' => [ - 'addon\aliapp\event\AliAuthNotify', // 服务订购通知 - 'addon\aliapp\event\AliAuditResult', // 小程序事件 - 'addon\aliapp\event\AlipayMerchant', // 直付通进件通知 - ], - 'AliPayMerchantPassed' => [ //支付宝二级商户进件成功 - 'addon\aliapp\event\AliPayMerchantPassed' - ], - 'AliappRegAuth' => [ //小程序注册授权通知 - 'addon\aliapp\event\AliappMiniReg' - ], - // 权益即将过期通知 - 'NoticeImpendingExpiration' => [ - 'addon\aliapp\event\NoticeImpendingExpiration' - ], - // 权益即将过期列表获取 - 'ImpendingExpirationListGet' => [ - 'addon\aliapp\event\ImpendingExpirationListGet' - ], - 'addMemberTemplate' => [ - 'addon\aliapp\event\addMemberTemplate' - ], - 'editMemberTemplate' => [ - 'addon\aliapp\event\editMemberTemplate' - ], - 'AlipayAuditPassed'=>[ //版本通过 - 'addon\aliapp\event\AlipayAuditPassed' - ], - 'AlipayServicemarketAddSite'=>[//服务注册账号短信 - 'addon\aliapp\event\AlipayServicemarketAddSite' - ], - 'PhoneNumber'=>[ - 'addon\aliapp\event\PhoneNumber' - ], - 'AliZmCloudPayNotify'=>[ //芝麻行业云 - 'addon\aliapp\event\PayNotify' - ], - 'AliPut' => [ //上传文件 - 'addon\aliapp\event\Put' - ], - 'checkAccess'=>[//检查接入状态 -// 'addon\aliapp\event\checkAccess' - ], - 'PaySecurityCheck'=>[ - 'addon\aliapp\event\PaySecurityCheck' - ], - 'VerifyCard'=>[ - 'addon\aliapp\event\VerifyCard' - ], - 'SubscribeMessages'=>[ - 'addon\aliapp\event\SubscribeMessages' - ] - ], - 'subscribe' => [], -]; diff --git a/addon/aliapp/config/info.php b/addon/aliapp/config/info.php deleted file mode 100644 index aae1502..0000000 --- a/addon/aliapp/config/info.php +++ /dev/null @@ -1,10 +0,0 @@ - 'aliapp', - 'title' => '支付宝小程序', - 'description' => '支付宝小程序,支付,电商社交', - 'status' => 1, - 'author' => '', - 'version' => '1.0', - 'content' => '', -]; \ No newline at end of file diff --git a/addon/aliapp/config/menu_admin.php b/addon/aliapp/config/menu_admin.php deleted file mode 100644 index 2dbeffd..0000000 --- a/addon/aliapp/config/menu_admin.php +++ /dev/null @@ -1,5 +0,0 @@ - 'SHOP_ALIAPP_ROOT', - 'title' => '支付宝小程序', - 'url' => 'aliapp://shop/aliapp/setting', - 'parent' => 'CHANNEL_ROOT', - 'picture' => 'addon/aliapp/shop/view/public/img/alipay_app_new.png', - 'picture_selected' => 'addon/aliapp/shop/view/public/img/alipay_app_select.png', - 'is_show' => 0, - 'sort' => 2, - 'child_list' => [ - [ - 'name' => 'ALIPAY_CONFIG', - 'title' => '基础配置', - 'url' => 'aliapp://shop/alipay/config', - 'is_show' => 0, - 'sort' => 2, - ], - [ - 'name' => 'ALIPAY_PACKAGE', - 'title' => '小程序发布', - 'url' => 'aliapp://shop/alipay/package', - 'is_show' => 0, - 'sort' => 3, - ], - [ - 'name' => 'ALIPAY_SHARE', - 'title' => '小程序分享', - 'url' => 'aliapp://shop/alipay/share', - 'is_show' => 0, - 'sort' => 6 - ], - [ - 'name' => 'ALIPAY_BASEINFO', - 'title' => '基础信息设置', - 'url' => 'aliapp://aliapp/shop/aliapp/editapp', - 'is_show' => 0, - 'sort' => 6 - ], - [ - 'name' => 'ALIPAY_RELEASE_APPLET', - 'title' => '发布小程序', - 'url' => 'aliapp://shop/AppletRelease/index', - 'is_show' => 1, - 'sort' => 2 - ], - [ - 'name' => 'ALIPAY_MEMBER_APPLET', - 'title' => '应用成员', - 'url' => 'aliapp://shop/member/index', - 'is_show' => 1, - 'sort' => 4 - ], - [ - 'name' => 'ALIAPP_PACKAGE_EDIT', - 'parent' => 'MESSAGE_LISTS', - 'title' => '编辑订阅消息', - 'url' => 'aliapp://shop/message/edit', - 'is_show' => 0, - 'sort' => 1, - ], - ] - ], - [ - 'title' => '支付宝维权订单', - 'name' => 'ALIPAY_ORDER_ROOT', - 'parent' => 'ORDER_MANAGE', - 'url' => 'aliapp://shop/order/batchquery', - 'is_show' => 0, - 'is_control' => 1, - 'is_icon' => 0, - 'picture' => 'icondingdan', - 'picture_selected' => '', - 'sort' => 21, - 'child_list'=>[ - [ - 'name' => 'ALIAPP_PACKAGE_TRADECOMPLAIN', - 'title' => '维权详情', - 'url' => 'aliapp://shop/order/complaindetail', - 'is_show' => 0, - 'sort' => 1, - ] - ] - ] -]; diff --git a/addon/aliapp/event/AliAuditResult.php b/addon/aliapp/event/AliAuditResult.php deleted file mode 100644 index 06aebd3..0000000 --- a/addon/aliapp/event/AliAuditResult.php +++ /dev/null @@ -1,121 +0,0 @@ -rsaCheck($param)) { - Log::write('支付宝小程序通知:' . $msgMethod . json_encode($param)); - $biz_content = json_decode($param['biz_content'], true); - $param['biz_content'] = $biz_content; - $res = event('AliGatewayNotify', $param, true); - switch ($msgMethod) { - case 'alipay.open.mini.version.audit.rejected'; //审核被拒绝 - $this->auditResultHandle($biz_content); - break; - case 'alipay.open.mini.version.audit.passed'; //审核通过 - $this->passed($biz_content); - break; - case 'alipay.open.mini.merchant.confirmed'; //小程序创建 - $this->confirmed($biz_content); - break; - case 'alipay.open.search.keyword.changed'; //小程序关键词审核进度消息通知 - echo 'success'; - break; - case 'alipay.open.mini.version.baseaudit.passed'; //小程序审核不可营销通知 - echo 'success'; - break; - default : - if ($res) { - if (is_string($res)) echo $res; - if (is_array($res)) echo json_encode($res); - } else { - echo 'success'; - } - } - } - } - - /** - * Common: 支付宝小程序审核结果处理 —— 驳回处理 - * Author: wu-hui - * Time: 2023/01/06 14:52 - * @param $param - * @throws \think\db\exception\DbException - */ - public function auditResultHandle($bizContent) - { - $siteIds = Db::name('uni_account')->where('appid', $bizContent['mini_app_id'])->column('site_id'); - Db::name('applet_release') - ->whereIn('site_id', $siteIds) - ->where('version', $bizContent['mini_app_version']) - ->update(['version_status' => 'AUDIT_REJECT', 'audit_reason' => $bizContent['audit_reason']]); - echo 'success'; - } - - - /*** - * 小程序创建 - * @param $param - */ - public function confirmed($bizContent) - { - $business_code = $bizContent['out_order_no']; - $where = [ - 'app_type' => 'aliapp', - 'business_code' => $business_code, - ]; - $info = Db::name('applet_reg')->where($where)->value('ag_site_id'); - if ($info) { - $data = [ - 'original_id' => $bizContent['pid'], - 'appid' => $bizContent['min_app_id'] ?? '', - 'status' => $bizContent['status'], - 'reg_fee' => model('website')->getValue(['site_id' => $info], 'appreg_rate'), - ]; - Db::name('applet_reg')->where($where)->update($data); - } - echo 'success'; - } - - /*** - * 小程序审核通过 - * @param $param - */ - public function passed($bizContent) - { - event('AlipayAuditPassed', $bizContent);//审核通过 - echo 'success'; - } - - /*** - * 验证签名 - * @param $param - * @return bool - */ - public function rsaCheck($param) - { - $payModel = new MinCode(); - $res = $payModel->verifySgin($param); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AliAuthNotify.php b/addon/aliapp/event/AliAuthNotify.php deleted file mode 100644 index b3ddf1a..0000000 --- a/addon/aliapp/event/AliAuthNotify.php +++ /dev/null @@ -1,25 +0,0 @@ -Notify($param); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AliMemberCardAuthNotify.php b/addon/aliapp/event/AliMemberCardAuthNotify.php deleted file mode 100644 index 528cadd..0000000 --- a/addon/aliapp/event/AliMemberCardAuthNotify.php +++ /dev/null @@ -1,26 +0,0 @@ -Notify($param); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AliPayMerchantPassed.php b/addon/aliapp/event/AliPayMerchantPassed.php deleted file mode 100644 index 1b77b5e..0000000 --- a/addon/aliapp/event/AliPayMerchantPassed.php +++ /dev/null @@ -1,25 +0,0 @@ -where('apps_id', '=', $param['auth_app_id']) - ->field('site_id,raw_data') - ->find(); - if ($res) { - $site_id = $res['site_id'] ?? ''; - $cloud_order_data = json_decode($res['raw_data'], true); - if ($res && $site_id) { - $paydata = [ - 'line_type' => 'auth', - 'app_type' => 'aliapp', - 'site_id' => $site_id ?? 0, - 'ag_site_id' => $ag_site_id ?? 0, - 'appid' => $param['auth_app_id'], - 'appsecret' => '', - 'token' => '', - 'app_name' => '', - 'head_img' => '', - 'qrcode' => '', - 'account' => $cloud_order_data['merchant_pid'], - 'alipay_public' => '', - 'private_key' => '', - 'app_auth_token' => $param['app_auth_token'], - 'app_refresh_token' => $param['app_refresh_token'], - 'app_original' => $cloud_order_data['merchant_pid'], - 'original_values' => $param, - ]; - $minapp = new Config(); - $minapp->setAlipayConfig($param['auth_app_id'], $paydata, $site_id, $paydata['app_original']); - } - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AlipayAuditPassed.php b/addon/aliapp/event/AlipayAuditPassed.php deleted file mode 100644 index 2f49286..0000000 --- a/addon/aliapp/event/AlipayAuditPassed.php +++ /dev/null @@ -1,39 +0,0 @@ -getInfo($where, 'id,site_id'); - if ($info) { - $release = new AliPayApplet($info['site_id']); - $release->publishingInit('version_online', $info['id']); - } - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AlipayMerchant.php b/addon/aliapp/event/AlipayMerchant.php deleted file mode 100644 index 72f8098..0000000 --- a/addon/aliapp/event/AlipayMerchant.php +++ /dev/null @@ -1,80 +0,0 @@ -rsaCheck($param); - if ($rsaCheck && $msgMethod) { - switch ($msgMethod) { - case 'ant.merchant.expand.indirect.zft.passed': - $this->passed(json_decode($param['biz_content'], true)); - break; - case 'ant.merchant.expand.indirect.zft.rejected': - $this->rejected(json_decode($param['biz_content'], true)); - break; - } - } - } - - /*** - * 审核成功 - * @param $param - */ - public function passed($param) - { - $business_code = $param['external_id'] ?? ''; - $info = Db::name('pay_shop')->where('business_code', '=', $business_code)->find(); - if ($info) { - $upData = [ - 'merchant_smid' => $param['smid'], - 'states' => 1, - 'apply_desc' => $param['memo'] - ]; - Db::name('pay_shop')->where('business_code', '=', $business_code)->update($upData); - event('AliPayMerchantPassed', array_merge($info, $param)); - } - echo 'success'; - } - - /*** - * 审核被拒绝 - * @param $param - */ - public function rejected($param) - { - $business_code = $param['external_id'] ?? ''; - $info = Db::name('pay_shop')->where('business_code', '=', $business_code)->find(); - if ($info) { - $upData = [ - 'apply_desc' => $param['reason'], - 'states' => 2, - ]; - Db::name('pay_shop')->where('business_code', '=', $business_code)->update($upData); - } - echo 'success'; - } - - - public function rsaCheck($param) - { - $payModel = new OpenPay(); - $res = $payModel->verifySgin($param); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/event/AlipayServicemarketAddSite.php b/addon/aliapp/event/AlipayServicemarketAddSite.php deleted file mode 100644 index 54e8948..0000000 --- a/addon/aliapp/event/AlipayServicemarketAddSite.php +++ /dev/null @@ -1,40 +0,0 @@ - $param['username'], - 2 => $param['password'], - ]; - $data['site_id'] = 1; - $data['site_info'] = [ - 'site_name' => '平台' - ]; - $data['message_info'] = [ - 'sms_is_open' => 1, - 'title' => '商家注册', - 'sms_json_array' => [ - 'cossms' => [ - 'template_id' => config('msg.template_id'), - 'content' => '您已订购服务登录账号{1}登录密码:{2}请妥善保管,如有疑问请咨询客服', - ] - ], - ]; - $sms_result = $sms_model->sendMessage($data); - if ($sms_result["code"] < 0) return $sms_result; - return success(); - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/DecryptData.php b/addon/aliapp/event/DecryptData.php deleted file mode 100644 index 3a7f8e7..0000000 --- a/addon/aliapp/event/DecryptData.php +++ /dev/null @@ -1,27 +0,0 @@ -decryptData($param); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/ImpendingExpirationListGet.php b/addon/aliapp/event/ImpendingExpirationListGet.php deleted file mode 100644 index 56a5812..0000000 --- a/addon/aliapp/event/ImpendingExpirationListGet.php +++ /dev/null @@ -1,127 +0,0 @@ -noticeHandle(); - - return $param; - } - /** - * Common: 权益即将过期列表获取 - * Author: wu-hui - * Time: 2023/01/11 10:25 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function noticeHandle(){ - // 获取所有开启通知的商家设置信息 - $configList = $this->getConfigList(); - // 获取即将过期信息 - $list = $this->getExpiringSoonList($configList); - $insertData = []; - foreach($list as $item){ - $insertData[] = [ - 'site_id' => $item['site_id'], - 'uid' => $item['member_id'], - 'member_goods_card' => $item['card_id'], - 'time_day' => $configList[$item['site_id']], - 'time_notice' => 0, - 'is_notice' => 0, - ]; - } - Db::name('member_goods_card_notice')->insertAll($insertData); - } - /** - * Common: 获取所有平台的 服务卡即将过期提前多少天提醒设置 - * Author: wu-hui - * Time: 2023/01/11 9:29 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function getConfigList(){ - $list = Db::name('config') - ->field("convert(json_extract(value,'$.days_in_advance'), signed) as days_in_advance,site_id") - ->where('config_key','ORDER_EVENT_TIME_CONFIG') - ->where("convert(json_extract(value,'$.days_in_advance'), signed) > 0") - ->select(); - if($list) { - $list = $list->toArray(); - - return array_column($list,'days_in_advance','site_id'); - } - - return []; - } - /** - * Common: 获取指定数量的即将过期信息列表 - * Author: wu-hui - * Time: 2023/01/11 10:20 - * @param $configList - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function getExpiringSoonList($configList){ - $list = []; - foreach($configList as $siteId => $days_in_advance){ - // 获取过期时间 - $endTime = strtotime("+{$days_in_advance} day"); - $list = array_merge($list,$this->getExpiringList($siteId,$endTime,(int)($this->limit - count($list)))); - if(count($list) >= $this->limit) break; - } - - return $list; - } - /** - * Common: 根据条件获取对应的信息列表 - * Author: wu-hui - * Time: 2023/01/11 10:20 - * @param $siteId - * @param $endTime - * @param $maxNum - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function getExpiringList($siteId,$endTime,$maxNum){ - $list = Db::name('member_goods_card')->alias('mgc') - ->join('member_goods_card_notice mgcn','mgcn.member_goods_card = mgc.card_id','left') - ->field('mgc.site_id,mgc.member_id,mgc.card_id') - ->where('mgc.site_id',$siteId) - ->where('mgc.end_time','<=',$endTime) - ->where('mgcn.id IS NULL') - ->order('mgc.end_time','ASC') - ->limit($maxNum) - ->select(); - - return $list ? $list->toArray() : []; - } - - - - - -} \ No newline at end of file diff --git a/addon/aliapp/event/Install.php b/addon/aliapp/event/Install.php deleted file mode 100644 index 4c88cf6..0000000 --- a/addon/aliapp/event/Install.php +++ /dev/null @@ -1,16 +0,0 @@ -noticeMessageHandle(); - - return $param; - } - /** - * Common: 权益即将过期通知 - * Author: wu-hui - * Time: 2023/01/11 10:43 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function noticeMessageHandle(){ - // 获取通知列表 - $list = $this->getList(); - $updateData = []; - foreach($list as $item){ - // 发送通知 - $res = (new AliPayMessage($item['site_id']))->sendMessage($item['member_id'],'INTEREST_EXPIRATION_NOTICE',[ - 'store_name' => $item['store_name'],// 商家名称 - 'surplus' => (int)$item['surplus'],// 剩余次数 - 'content' => $item['goods_name'],// 优惠内容 - ]); - // 发送成功 - if($res['code'] == 0){ - $updateData[] = [ - 'id' => $item['id'], - 'time_notice' => time(), - 'is_notice' => 1, - ]; - } - } - (new NewBaseModel(['table_name'=>'member_goods_card_notice']))->saveAll($updateData); - } - /** - * Common: 获取通知列表 - * Author: wu-hui - * Time: 2023/01/11 10:38 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function getList(){ - $list = Db::name('member_goods_card_notice')->alias('mgcn') - ->join('member_goods_card mgc','mgcn.member_goods_card = mgc.card_id','left') - ->join('store','mgc.store_id = store.store_id','left') - ->field('mgcn.id,mgc.site_id,mgc.member_id,mgc.goods_name,(mgc.total_num - mgc.total_use_num) as surplus,store.store_name') - ->where('mgcn.id','>',0) - ->where('mgcn.is_notice',0) - ->order('mgcn.id','ASC') - ->limit($this->limit) - ->select(); - - return $list ? $list->toArray() : []; - } - - -} \ No newline at end of file diff --git a/addon/aliapp/event/OrderPay.php b/addon/aliapp/event/OrderPay.php deleted file mode 100644 index 82a740f..0000000 --- a/addon/aliapp/event/OrderPay.php +++ /dev/null @@ -1,27 +0,0 @@ -settleConfirm($param['order_id']); - return $param; - } - -} \ No newline at end of file diff --git a/addon/aliapp/event/PayNotify.php b/addon/aliapp/event/PayNotify.php deleted file mode 100644 index ca50c5f..0000000 --- a/addon/aliapp/event/PayNotify.php +++ /dev/null @@ -1,29 +0,0 @@ -payNotify(); - }else{ - echo 'fail'; - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/PaySecurityCheck.php b/addon/aliapp/event/PaySecurityCheck.php deleted file mode 100644 index 43f6656..0000000 --- a/addon/aliapp/event/PaySecurityCheck.php +++ /dev/null @@ -1,18 +0,0 @@ -PaySecurityCheck(); - } else { - return error(-1, '站点ID不存在'); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/PhoneNumber.php b/addon/aliapp/event/PhoneNumber.php deleted file mode 100644 index 18eaf47..0000000 --- a/addon/aliapp/event/PhoneNumber.php +++ /dev/null @@ -1,16 +0,0 @@ -getUserPhoneNumber($param); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/Put.php b/addon/aliapp/event/Put.php deleted file mode 100644 index 7036703..0000000 --- a/addon/aliapp/event/Put.php +++ /dev/null @@ -1,12 +0,0 @@ -putFile($param); - return $result; - } -} \ No newline at end of file diff --git a/addon/aliapp/event/Qrcode.php b/addon/aliapp/event/Qrcode.php deleted file mode 100644 index c8e1950..0000000 --- a/addon/aliapp/event/Qrcode.php +++ /dev/null @@ -1,24 +0,0 @@ -createQrcode($param); - return $res; - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/SendMessageTemplate.php b/addon/aliapp/event/SendMessageTemplate.php deleted file mode 100644 index cf037d2..0000000 --- a/addon/aliapp/event/SendMessageTemplate.php +++ /dev/null @@ -1,64 +0,0 @@ -OrderCreateMsg(); - case 'ORDER_PAY': //订单支付 - $model->messagePaySuccess(); - break; - case 'ORDER_DELIVERY': //订单发货 - $model->messageOrderDelivery(); - break; - case 'ORDER_URGE_PAYMENT'://订单催款待支付 - $model->messageOrderUrgePayment(); - break; - case 'ORDER_CLOSE': //订单关闭 - $model->messageOrderClose(); - break; - case 'ORDER_COMPLETE': //订单完成 - $model->messageBuyerOrderComplete(); - break; - case 'ORDER_REFUND_AGREE'://商家同意退款 - $model->MessageOrderRefundinG(); - break; - case 'ORDER_REFUND_AGREE'://转账完成 - $model->messageOrderRefundAgree(); - break; - case 'ORDER_REFUND_REFUSE': //商家拒绝退款 - $model->messageOrderRefundRefuse(); - case 'VERIFY': //订单核销 - $model->messageOrderVerify(); - break; - } - } catch (\Exception $e) { - Log::write('支付宝订单消息:' . $e->getMessage() . json_encode($param)); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/event/ShowPromotion.php b/addon/aliapp/event/ShowPromotion.php deleted file mode 100644 index 3cef1d7..0000000 --- a/addon/aliapp/event/ShowPromotion.php +++ /dev/null @@ -1,49 +0,0 @@ - [ - [ - //插件名称 - 'name' => 'aliapp', - //店铺端展示分类 shop:营销活动 member:互动营销 - 'show_type' => 'tool', - //展示主题 - 'title' => '支付宝小程序', - //展示介绍 - 'description' => '支付宝小程序', - //展示图标 - 'icon' => 'addon/aliapp/icon.png', - //跳转链接 - 'url' => 'aliapp://shop/aliapp/setting', - //是否开发中仅展示 - 'is_developing' => 0 - ] - ] - ]; - return $data; - } -} \ No newline at end of file diff --git a/addon/aliapp/event/SubLedger.php b/addon/aliapp/event/SubLedger.php deleted file mode 100644 index 240b2c7..0000000 --- a/addon/aliapp/event/SubLedger.php +++ /dev/null @@ -1,30 +0,0 @@ - 0){ - $siteId = Db::name('order')->where('order_id',$orderId)->value('site_id'); - (new AliPaySubLedger($siteId))->orderSettle($orderId); - } - return $param; - } -} \ No newline at end of file diff --git a/addon/aliapp/event/SubscribeMessages.php b/addon/aliapp/event/SubscribeMessages.php deleted file mode 100644 index 0f8e531..0000000 --- a/addon/aliapp/event/SubscribeMessages.php +++ /dev/null @@ -1,16 +0,0 @@ -params['keywords'] ?? ''; - $message = new Message(); - $res = $message->getMessageTmplIds($params['site_id'], $keywords); - return $res; - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/UnInstall.php b/addon/aliapp/event/UnInstall.php deleted file mode 100644 index de5baba..0000000 --- a/addon/aliapp/event/UnInstall.php +++ /dev/null @@ -1,16 +0,0 @@ -getInfo([['site_id', '=', $param['site_id']], ['verify_code', '=', $param['verify_code']]], 'id, site_id, verify_code, verify_type, verify_type_name, verify_content_json, verifier_id, verifier_name, is_verify, expire_time, verify_total_count, verify_use_num, store_id'); - if ($verify_info) { - $CloudPay = new CloudPay(); - $response = $CloudPay->verify($verify_info['temp_verify_code']);//芝麻核销 - if ($response['response']['code'] != 10000) { - if ($response['response']['sub_code'] == 2042) { - return success(0, '核销成功-' . $response['response']['msg'] . '-' . $response['response']['sub_msg']); - } else { - return error(-1, '核销失败-' . $response['response']['msg'] . '-' . $response['response']['sub_msg']); - } - } else { - return success(0, '核销成功-' . $response['response']['msg']); - } - } else { - return error(-1, '核销码不属于该商家'); - } - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/addMemberTemplate.php b/addon/aliapp/event/addMemberTemplate.php deleted file mode 100644 index 4209ff9..0000000 --- a/addon/aliapp/event/addMemberTemplate.php +++ /dev/null @@ -1,22 +0,0 @@ -addTemplate($param); - return $res; - } - return success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/event/checkAccess.php b/addon/aliapp/event/checkAccess.php deleted file mode 100644 index db04569..0000000 --- a/addon/aliapp/event/checkAccess.php +++ /dev/null @@ -1,8 +0,0 @@ -site_id = $site_id; - } - - /*** - * 创建模版 - * @param $data - * @return array|void - */ - public function addTemplate($data) - { - $rgb = $this->hex2rgb($data['bg_color']); - $ali = new CloudPay(); - $aliData = [ - 'card_show_name' => $data['level_name'], - 'bg_color' => 'rgb(' . $rgb['r'] . ',' . $rgb['g'] . ',' . $rgb['b'] . ')', - 'logo_id' => $ali->imageUpload($this->site_id, $data['level_logo'], 'level_logo', true)['data']['image_id'], - 'background_id' => $ali->imageUpload($this->site_id, $data['level_picture'], 'level_picture', true)['data']['image_id'], - ]; - $template = $this->alipayMarketingCardTemplateCreate($this->site_id, array_merge($aliData, $data));//创建下小程序模版 - if ($template['code'] < 0) return $template; - $data['alipay_marketing_card_template_id'] = $template['data']['template_id']; - $formtemplateSet = $this->alipayMarketingCardFormtemplateSet($this->site_id, $template['data']['template_id']); - if ($formtemplateSet['code'] < 0) return $formtemplateSet; - return $template; - } - - - public function editTemplate() - { - - - } - - - public function delTemplate() - { - - - } - - - /** - * 获取站点推荐会员卡 - * @param $site_id - */ - public function getAliMemberCard($site_id) - { - $condition = [ - ['site_id', '=', $site_id], - ['status', '=', 1], - ['alipay_marketing_card_template_id', '<>', ''] - ]; - $field = 'level_id,level_name,consume_discount,is_free_shipping,point_feedback,send_point,send_balance,send_coupon,charge_rule,alipay_marketing_card_template_id'; - $data = model('member_level')->getInfo($condition, $field); - // 获取支付宝支付参数(统一支付到平台账户) - $config_model = new \addon\aliapp\model\Config(); - $config_info = $config_model->getAppConfig($site_id)['data']; - $data['appid'] = $config_info['appid']; - return $this->success($data); - } - - /*** - * 创建支付宝商家会员卡 - * @param $site_id - * @param $data - * @return array - */ - public function alipayMarketingCardTemplateCreate($site_id, $data) - { - // 获取支付宝支付参数(统一支付到平台账户) - $config_model = new \addon\aliapp\model\Config(); - $config_info = $config_model->getAppConfig($site_id)['data']; - $platform_config_info = config('alipay.platform'); - $ali = new CloudPay(); - $a = 'A*zCGWRbRjnSoAAAAAAAAAAAAABKd2AQ'; - $b = 'A*yf7PTZGSorcAAAAAAAAAAAAABKd2AQ'; - $c = 'A*i8CkTIsG9dkAAAAAAAAAAAAABKd2AQ'; - $params = [ - 'request_id' => substr($this->uuid(), 0, 20), - 'card_type' => 'OUT_MEMBER_CARD', - 'biz_no_suffix_len' => '20', - 'write_off_type' => 'qrcode', - 'template_style_info' => [ - 'card_show_name' => $data['card_show_name'], - 'logo_id' => $data['logo_id'], - 'background_id' => $data['background_id'], - 'bg_color' => $data['bg_color'], -// 'feature_descriptions' => $data['remark'], - ], -// 'template_benefit_info'=>[ -// 'title'=>$data['remark'], -// 'benefit_desc'=>$data['remark'], -// 'end_date'=>$data['remark'], -// ], - 'column_info_list' => [ - [ - 'code' => 'MY_HOME', - 'operate_type' => 'openWeb', - 'title' => '商城主页', - 'more_info' => [ - 'title' => '商城主页', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] - ] - ], - [ - 'code' => 'MEMBER_INFO', - 'operate_type' => 'openWeb', - 'title' => '会员中心', - 'more_info' => [ - 'title' => '个人中心', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages/member/index' - ] - ], - [ - 'code' => 'BALANCE', - 'operate_type' => 'openWeb', - 'title' => '余额', - 'more_info' => [ - 'title' => '个人中心', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages/member/index' - ] - ], - [ - 'code' => 'MY_ORDER', - 'operate_type' => 'openWeb', - 'title' => '我的订单', - 'more_info' => [ - 'title' => '我的订单', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages_market/order/list' - ] - ], - [ - 'code' => 'CARD_INFO', - 'operate_type' => 'openWeb', - 'title' => '会员卡详情', - 'more_info' => [ - 'title' => '会员卡详情', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages_tool/member/card' - ] - ], - [ - 'code' => 'MINI_SHOP', - 'operate_type' => 'openWeb', - 'title' => '售后服务', - 'more_info' => [ - 'title' => '售后服务', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'].'&page=pages_tool/order/activist' - ] - ], - ], - 'field_rule_list' => [ - [ - 'field_name' => 'Balance', - 'rule_name' => 'ASSIGN_FROM_REQUEST', - 'rule_value' => 'Balance' - ] - ], - 'card_action_list' => [ - [ - 'code' => 'GO_APPOINTMENT', - 'text' => '会员签到', - 'url_type' => 'miniAppUrl', - 'mini_app_url' => [ - 'mini_app_id' => $config_info['appid'], - 'mini_page_param' => 'pages_tool/member/signin', - 'display_on_list' => 'false' - ] - ], - [ - 'code' => 'MY_APPOINTMENT', - 'text' => '优惠券', - 'url_type' => 'miniAppUrl', - 'mini_app_url' => [ - 'mini_app_id' => $config_info['appid'], - 'mini_page_param' => 'pages_tool/member/coupon', - 'display_on_list' => 'false' - ] - ] - ], - 'open_card_conf' => [ - 'open_card_source_type' => 'MER', - 'source_app_id' => $platform_config_info["appid"] ?? "", - 'open_card_url' => addon_url('aliapp/shop/membercard/receive',['appid'=>$config_info['appid']]), - 'card_rights' => [ - [ - 'title' => '入会有礼', - 'logo_id' => $a, - ], - [ - 'title' => '在线预约', - 'logo_id' => $b, - ], - [ - 'title' => '专属福利', - 'logo_id' => $c, - ], - ], - ], - 'spi_app_id' => $platform_config_info["appid"] ?? "" - ]; - - return $this->success(cache('alipay_marketing_card_template_create_response')); - // 发起请求 - $result = (new MinCode($site_id))->requestApi('alipay.marketing.card.template.create', $params, []); - $result = $result['alipay_marketing_card_template_create_response']; - if ($result['code'] == 10000) { - cache('alipay_marketing_card_template_create_response',$result); - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - public function alipayMarketingCardTemplateModify($site_id, $template_id, $data) - { - // 获取支付宝支付参数(统一支付到平台账户) - $config_model = new \addon\aliapp\model\Config(); - $config_info = $config_model->getAppConfig($site_id)['data']; - - $ali = new CloudPay(); - $a = 'A*zCGWRbRjnSoAAAAAAAAAAAAABKd2AQ'; - $b = 'A*yf7PTZGSorcAAAAAAAAAAAAABKd2AQ'; - $c = 'A*i8CkTIsG9dkAAAAAAAAAAAAABKd2AQ'; - $params = [ - 'request_id' => substr($this->uuid(), 0, 20), - 'template_id' => $template_id, - // 'card_type' => 'OUT_MEMBER_CARD', - 'biz_no_suffix_len' => '20', - 'write_off_type' => 'qrcode', - 'template_style_info' => [ - 'card_show_name' => $data['card_show_name'], - 'logo_id' => $data['logo_id'], - 'background_id' => $data['background_id'], - 'bg_color' => $data['bg_color'], - ], - 'column_info_list' => [ - [ - 'code' => 'BALANCE', - 'operate_type' => 'openWeb', - 'title' => '余额', - 'more_info' => [ - 'title' => '个人中心', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages/member/index' - ] - ], - [ - 'code' => 'MEMBER_INFO', - 'operate_type' => 'openWeb', - 'title' => '个人中心', - 'more_info' => [ - 'title' => '个人中心', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages/member/index' - ] - ], - [ - 'code' => 'MY_CARD', - 'operate_type' => 'openWeb', - 'title' => '我的服务卡', - 'more_info' => [ - 'title' => '我的服务卡', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages_service/service_card/list' - ] - ], - [ - 'code' => 'MY_ORDER', - 'operate_type' => 'openWeb', - 'title' => '我的订单', - 'more_info' => [ - 'title' => '我的订单', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] . '&page=pages_service/service_order/list' - ] - ], - // [ - // 'code' => 'CARD_INFO', - // 'operate_type' => 'openWeb', - // 'title' => '会员卡详情', - // 'more_info' => [ - // 'title' => '会员卡详情', - // 'url' => 'alipays://platformapi/startapp?appId='.$config_info['appid'].'&page=pages/member/index' - // ] - // ], - [ - 'code' => 'MINI_SHOP', - 'operate_type' => 'openWeb', - 'title' => '小程序商城', - 'more_info' => [ - 'title' => '小程序商城', - 'url' => 'alipays://platformapi/startapp?appId=' . $config_info['appid'] - ] - ], - ], - 'field_rule_list' => [ - [ - 'field_name' => 'Balance', - 'rule_name' => 'ASSIGN_FROM_REQUEST', - 'rule_value' => 'Balance' - ] - ], - 'card_action_list' => [ - [ - 'code' => 'GO_APPOINTMENT', - 'text' => '去预约', - 'url_type' => 'miniAppUrl', - 'mini_app_url' => [ - 'mini_app_id' => $config_info['appid'], - 'mini_page_param' => 'pages_promotion/cardservice/service_goods/reserve_apply', - 'display_on_list' => 'false' - ] - ], - [ - 'code' => 'MY_APPOINTMENT', - 'text' => '我的预约', - 'url_type' => 'miniAppUrl', - 'mini_app_url' => [ - 'mini_app_id' => $config_info['appid'], - 'mini_page_param' => 'pages_promotion/cardservice/service_goods/my_reserve_list', - 'display_on_list' => 'false' - ] - ] - ], - 'open_card_conf' => [ - 'open_card_source_type' => 'MER', - 'source_app_id' => '2021003167617037', - 'open_card_url' => 'https://www.alipay.com', - 'card_rights' => [ - [ - 'title' => '入会有礼', - 'logo_id' => $a, - ], - [ - 'title' => '专属福利', - 'logo_id' => $c, - ], - [ - 'title' => '在线预约', - 'logo_id' => $b, - ] - ], - ], - 'spi_app_id' => '2021003167617037' - ]; - // 发起请求 - $result = (new MinCode($site_id))->requestApi('alipay.marketing.card.template.modify', $params, []); - - $result = $result['alipay_marketing_card_template_modify_response']; - if ($result['code'] == 10000) { - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - - /*** - * 设置开卡必填信息 - * @param $site_id - * @param $template_id - * @return array - */ - public function alipayMarketingCardFormtemplateSet($site_id, $template_id) - { - $params = [ - "template_id" => $template_id, - 'fields' => [ - 'required' => '{"common_fields": [ "OPEN_FORM_FIELD_NAME", "OPEN_FORM_FIELD_GENDER", "OPEN_FORM_FIELD_MOBILE", "OPEN_FORM_FIELD_BIRTHDAY" ] }' - ] - ]; - // 发起请求 - $result = (new MinCode($site_id))->requestApi('alipay.marketing.card.formtemplate.set', $params, []); - $result = $result['alipay_marketing_card_formtemplate_set_response']; - if ($result['code'] == 10000) { - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - /** - * 生成UUID - */ - public function uuid() - { - $chars = md5(uniqid(mt_rand(), true)); - $uuid = substr($chars, 0, 8) . '-' - . substr($chars, 8, 4) . '-' - . substr($chars, 12, 4) . '-' - . substr($chars, 16, 4) . '-' - . substr($chars, 20, 12); - return $uuid; - } - - /** - * 会员卡更新 - * @param $site_id - * @param $template_id - * @param $data - * @return array - */ - public function alipayMarketingCardUpdate($site_id, $member_id) - { - - $memberInfo = model('member')->getInfo([['member_id', '=', $member_id]]); - if (empty($memberInfo)) { - return $this->error('用户信息不存在'); - } - - if (isset($memberInfo['alipay_biz_card_no']) && $memberInfo['alipay_biz_card_no'] == '') { - return $this->error('支付宝会员卡信息不存在'); - } - - if (isset($memberInfo['alipay_card_open_date']) && $memberInfo['alipay_card_open_date'] == '') { - return $this->error('支付宝会员卡信息不存在'); - } - - if (isset($memberInfo['alipay_card_valid_date']) && $memberInfo['alipay_card_valid_date'] == '') { - return $this->error('支付宝会员卡信息不存在'); - } - - $params = [ - 'target_card_no' => $memberInfo['alipay_biz_card_no'], - 'target_card_no_type' => 'BIZ_CARD', - 'occur_time' => date('Y-m-d H:i:s', time()), - 'card_info' => [ - 'biz_card_no' => $memberInfo['alipay_biz_card_no'], - 'external_card_no' => $memberInfo['member_id'] + 1000000000, - 'open_date' => $memberInfo['alipay_card_open_date'], - 'valid_date' => $memberInfo['alipay_card_valid_date'], - 'balance' => $memberInfo['balance'] + $memberInfo['balance_money'] - ], - ]; - // 发起请求 - $result = (new MinCode($site_id))->requestApi('alipay.marketing.card.update', $params, []); - - $result = $result['alipay_marketing_card_update_response']; - if ($result['code'] == 10000) { - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - - /** - * 将16进制颜色转换为RGB - * author www.zwyuanma.com - */ - private function hex2rgb($hexColor) - { - $color = str_replace('#', '', $hexColor); - if (strlen($color) > 3) { - $rgb = array( - 'r' => hexdec(substr($color, 0, 2)), - 'g' => hexdec(substr($color, 2, 2)), - 'b' => hexdec(substr($color, 4, 2)) - ); - } else { - $r = substr($color, 0, 1) . substr($color, 0, 1); - $g = substr($color, 1, 1) . substr($color, 1, 1); - $b = substr($color, 2, 1) . substr($color, 2, 1); - $rgb = array( - 'r' => hexdec($r), - 'g' => hexdec($g), - 'b' => hexdec($b) - ); - } - return $rgb; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AliPayApplet.php b/addon/aliapp/model/AliPayApplet.php deleted file mode 100644 index c210155..0000000 --- a/addon/aliapp/model/AliPayApplet.php +++ /dev/null @@ -1,572 +0,0 @@ -site_id = $siteId; - $this->templateInfo = config('alipay.templateInfo'); - $this->version = config('alipay.version'); - } - - - /** - * Common: 小程序发布记录 查询集合 - * Author: wu-hui - * Time: 2022/12/29 18:38 - * @return Db - */ - private function appletReleaseSelectCollection($type) - { - return Db::name('applet_release') - ->where('site_id', $this->site_id) - ->where('type', $type); - } - - /** - * Common: 获取已发布的最新版本 - * Author: wu-hui - * Time: 2023/01/03 16:41 - * @return string - */ - public function newestVersion(): string - { - $version = (string)$this->appletReleaseSelectCollection(1) - ->order(['create_time' => 'desc', 'id' => 'desc']) - ->value('version'); - - return !empty($version) ? $version : '0.0.0'; - } - - /** - * Common: 判断:当前版本是否为最新版本 - * Author: wu-hui - * Time: 2023/01/03 17:07 - * @return bool - */ - public function isNewestVersion($app_version=''): bool - { - $user_version=$this->newestVersion(); - if($app_version && $user_version=='0.0.0'){ - return true; - }else if(empty($app_version)){ - return (boolean)version_compare($this->version, $user_version, '>'); - }else{ - return (boolean)version_compare($app_version, $user_version, '>'); - } - } - - /** - * Common: 发布流程处理 —— 开始处理 - * Author: wu-hui - * Time: 2023/01/04 10:49 - * @param $type - * @param $id - * @return array - */ - public function publishingInit($type, $id,$app_version='') - { - try { - // 根据操作类型获取对应信息 - $config = $this->publishingConfig($type); - [$params, $textParams, $extra] = $this->publishingParams($type, $id,$app_version); - // 发起请求 - $result = (new MinCode($this->site_id))->requestApi($config['api'], $params, $textParams); - $result = $result[$config['result_key']] ?? ['code' => 0]; - if ($result['code'] == 10000) { - $res = $this->resultProcessing($type, $id, $result, $extra); - if ($res) return success(0, $res); - else return $this->success(); - } else { - return $this->error('', $result['sub_msg']); - } - } catch (\Exception $e) { - return $this->error('', $e->getMessage()); - } - } - - /** - * Common: 发布流程处理 —— 根据操作类型获取配置信息 - * Author: wu-hui - * Time: 2023/01/04 10:09 - * @param $type - * @return string[] - * @throws Exception - */ - private function publishingConfig($type): array - { - $list = [ - 'delete' => [ - 'api' => 'alipay.open.mini.version.delete', // 请求接口 - 'result_key' => 'alipay_open_mini_version_delete_response',// 返回结果字段名称 - ], - 'release_experience_version' => [ - 'api' => 'alipay.open.mini.experience.create', - 'result_key' => 'alipay_open_mini_experience_create_response', - ], - 'cancel_experience_version' => [ - 'api' => 'alipay.open.mini.experience.cancel', - 'result_key' => 'alipay_open_mini_experience_cancel_response', - ], - 'see_experience_version' => [ - 'api' => 'alipay.open.mini.experience.query', - 'result_key' => 'alipay_open_mini_experience_query_response', - ], - 'audit_submit' => [ - 'api' => 'alipay.open.mini.version.audit.apply', - 'result_key' => 'alipay_open_mini_version_audit_apply_response', - ], - 'audit_cancel' => [ - 'api' => 'alipay.open.mini.version.audit.cancel', - 'result_key' => 'alipay_open_mini_version_audit_cancel_response', - ], - 'audited_cancel' => [ - 'api' => 'alipay.open.mini.version.audited.cancel', - 'result_key' => 'alipay_open_mini_version_audited_cancel_response', - ], - 'version_online' => [ - 'api' => 'alipay.open.mini.version.online', - 'result_key' => 'alipay_open_mini_version_online_response', - ], - 'version_gray_online' => [ - 'api' => 'alipay.open.mini.version.gray.online', - 'result_key' => 'alipay_open_mini_version_gray_online_response', - ], - 'version_gray_cancel' => [ - 'api' => 'alipay.open.mini.version.gray.cancel', - 'result_key' => 'alipay_open_mini_version_gray_cancel_response', - ], - 'version_offline' => [ - 'api' => 'alipay.open.mini.version.offline', - 'result_key' => 'alipay_open_mini_version_offline_response', - ], - 'version_rollback' => [ - 'api' => 'alipay.open.mini.version.rollback', - 'result_key' => 'alipay_open_mini_version_rollback_response', - ], - 'version_upload' => [ - 'api' => 'alipay.open.mini.version.upload', - 'result_key' => 'alipay_open_mini_version_upload_response', - ], - ]; - if ($list[$type]) return $list[$type]; - else throw new Exception('无效的操作!'); - } - - /** - * Common: 发布流程处理 —— 根据操作类型生成接口请求参数 - * Author: wu-hui - * Time: 2023/01/04 10:32 - * @param $type - * @param $id - * @param $app_version - * @return array[] - * @throws Exception - */ - private function publishingParams($type, $id,$app_version='') - { - $params = $textParams = $extra = []; - // 根据类型进行对应的操作 - switch ($type) { - case 'delete': - case 'release_experience_version': - case 'cancel_experience_version': - case 'see_experience_version': - case 'audit_cancel': - case 'audited_cancel': - case 'version_online': - case 'version_gray_cancel': - case 'version_offline': - case 'version_rollback': - $params = [ - 'app_version' => $this->getVersion($id), - 'bundle_id' => $this->bundle_id, - ]; - break; - case 'audit_submit': - $version = $this->getVersion($id); - $textParams = [ - 'region_type' => 'CHINA', - 'version_desc' => "发布{$version}版本", - 'app_version' => $version, //商家自定义版本 - 'bundle_id' => $this->bundle_id, - 'speed_up' => 'false', - 'auto_online' => 'auto_online' - ]; - break; - case 'version_gray_online': - $params = [ - 'app_version' => $this->getVersion($id), - 'gray_strategy' => 'p10',// 枚举支持:p10、p30、p50 - 'bundle_id' => $this->bundle_id, - ]; - break; - case 'version_upload': -// $res = event('getDivideAccounts', ['site_id' => $this->site_id], true); -// if ($res) { -// $micode = new MinCode($this->site_id); -// $request = $micode->requestApi('alipay.trade.royalty.relation.batchquery', ['out_request_no' => date('YmdHisw')])['alipay_trade_royalty_relation_batchquery_response']; -// if ($request['code'] != 10000) { -// throw new Exception('分账状态异常:' . $request['sub_msg']); -// } -// } - if($app_version){ - $this->version=$app_version; - } - // 获取最新版本 - $isNewestVersion = (new AliPayApplet($this->site_id))->isNewestVersion($app_version); - if (!$isNewestVersion) throw new Exception('当前版本为最新版本,请勿重复发布!'); - // 获取默认门店id - $storeInfo = Db::name('store') - ->where('site_id', $this->site_id) - ->where('is_default', 1) - ->field('store_id,store_id,store_name') - ->find(); - if (empty($storeInfo)) throw new Exception('默认门店不存在,请添加后进行操作!'); - // 判断:是否存在小程序配置信息 - $hasAccount = Db::name('uni_account')->where(['site_id' => $this->site_id, 'app_type' => 'aliapp'])->value('appid'); - if ($hasAccount <= 0) throw new Exception('请先配置小程序!'); - $extra = ['appid' => $hasAccount]; - $ext = [ - 'extEnable' => true, - 'ext' => [ - 'site_id' => $this->site_id, - 'store_id' => $storeInfo['store_id'], - ], - 'window' => [ - 'defaultTitle' => $storeInfo['store_name'] - ], - ]; - $params = [ - 'template_version' => $this->templateInfo['template_version'],// 小程序模板版本号 - 'ext' => json_encode($ext),//自定义参数 - 'template_id' => $this->templateInfo['template_id'],// 小程序模板 APPID - 'app_version' => $this->version,//商家小程序版本号 - 'bundle_id' => $this->bundle_id, - ]; - break; - default: - throw new Exception('无效的操作!'); - } - return [$params, $textParams, $extra]; - } - - /** - * Common: 发布流程处理 —— 根据id获取版本信息 - * Author: wu-hui - * Time: 2023/01/04 10:18 - * @param $id - * @return mixed - * @throws Exception - */ - private function getVersion($id) - { - $version = Db::name('applet_release')->where('id', $id)->value('version'); - if (!$version) throw new Exception('版本不存在!'); - return $version; - } - - /** - * Common: 发布流程处理 —— 请求结果处理 - * Author: wu-hui - * Time: 2023/01/04 10:46 - * @param $type - * @param $id - * @param $result - * @return string - * @throws \think\db\exception\DbException - */ - private function resultProcessing($type, $id, $result, $extra = []) - { - $returnData = ''; - switch ($type) { - case 'delete': - Db::name('applet_release')->where('id', $id)->delete(); - break; // 删除版本 - case 'release_experience_version': - $this->appletReleaseSelectCollection(1)->update(['is_experience_version' => 0]); - Db::name('applet_release')->where('id', $id)->update(['is_experience_version' => 1]); - break;// 发布体验版本 - case 'cancel_experience_version': - Db::name('applet_release')->where('id', $id)->update(['is_experience_version' => 0]); - break;// 取消体验版发布 - case 'see_experience_version': - $statusText = [ - 'expVersionPackged' => '体验版打包成功', - 'expVersionPackaging' => '体验版打包中', - 'notExpVersion' => '非体验版', - ]; - $returnData = $statusText[$result['status']]; - break;// 体验版状态查看 - case 'audit_submit': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'AUDITING']); - break;// 提交审核 - case 'audit_cancel': - case 'audited_cancel': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'INIT']); - break;// 撤销审核 & 退回开发 - case 'version_online': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'RELEASE']); - break;//上架 - case 'version_gray_online': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'GRAY']); - break;//灰度上架 - case 'version_gray_cancel': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'WAIT_RELEASE']); - break;//结束灰度 - case 'version_offline': - Db::name('applet_release')->where('id', $id)->update(['version_status' => 'OFFLINE']); - break;// 下架 - case 'version_rollback': - $this->versionSee($id); - break;// 回滚 - case 'version_upload': - $version = config('alipay.templateInfo.template_version'); - $data = [ - 'site_id' => $this->site_id, - 'appid' => $extra['appid'], - 'version' => $version, - 'type' => 1, - 'ali_create_status' => $result['create_status'], - 'version_status' => 'INIT', - 'create_time' => time(), - ]; - Db::name('applet_release')->insert($data); - break;// 发布新版本 - } - return $returnData; - } - - - /** - * Common: 版本管理 —— 所有版本同步 - * Author: wu-hui - * Time: 2022/12/30 9:58 - * @return array - * @throws \Exception - */ - public function versionSynchronization() - { - $params = [ - 'bundle_id' => $this->bundle_id, - // 版本状态:INIT=开发中,AUDITING=审核中,AUDIT_REJECT=审核驳回,WAIT_RELEASE=待上架,BASE_AUDIT_PASS=准入不可营销,GRAY=灰度中,RELEASE=已上架,OFFLINE=已下架,AUDIT_OFFLINE: 已下架 - 'version_status' => 'INIT,AUDITING,AUDIT_REJECT,WAIT_RELEASE,BASE_AUDIT_PASS,GRAY,RELEASE,OFFLINE,AUDIT_OFFLINE', - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.mini.version.list.query', $params); - $result = $result['alipay_open_mini_version_list_query_response']; - if ($result['code'] == 10000) { - // 同步版本信息 - $appVersionInfos = $result['app_version_infos'] ?? []; - $hasList = $this->appletReleaseSelectCollection(1)->column('version', 'id'); - $hasListIds = array_flip($hasList); - $insertData = []; - $updateData = []; - foreach ($appVersionInfos as $val) { - if (!in_array($val['app_version'], $hasList)) { - $insertData[] = [ - 'site_id' => $this->site_id, - 'version' => $val['app_version'], - 'type' => 1, - 'ali_create_status' => 0, - 'version_status' => $val['version_status'], - 'create_time' => strtotime($val['create_time']), - ]; - } else { - $updateData[] = [ - 'id' => $hasListIds[$val['app_version']], - 'version_status' => $val['version_status'], - ]; - } - } - Db::name('applet_release')->insertAll($insertData); - (new NewBaseModel(['table_name' => 'applet_release']))->saveAll($updateData); - - return $this->success(); - } else { - return $this->error('', $result['sub_msg']); - } - } - - /** - * Common: 版本管理 —— 查询小程序版本构建状态 - * Author: wu-hui - * Time: 2022/12/29 17:45 - * @param $version - * @param $id - * @return array|mixed - * @throws \think\db\exception\DbException - */ - public function versionBuildQuery($version, $id) - { - $params = [ - 'app_version' => $version, - 'bundle_id' => $this->bundle_id, - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.mini.version.build.query', $params); - $result = $result['alipay_open_mini_version_build_query_response']; - - if ($result['code'] == 10000) { - Db::name('applet_release')->where('id', $id)->update(['ali_create_status' => $result['create_status']]); - - return $result['create_status']; - } else { - return $this->error('', $result['sub_msg']); - } - } - - /** - * Common: 版本管理 —— 版本详情查询 - * Author: wu-hui - * Time: 2022/12/30 16:54 - * @param $id - * @return array - * @throws \think\db\exception\DbException - */ - public function versionSee($id) - { - $version = Db::name('applet_release')->where('id', $id)->value('version'); - if (!$version) $this->error('', '版本不存在!'); - $params = [ - 'app_version' => $version, - 'bundle_id' => $this->bundle_id, - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.mini.version.detail.query', $params); - $result = $result['alipay_open_mini_version_detail_query_response']; - if ($result['code'] == 10000) { - Db::name('applet_release')->where('id', $id)->update(['version_status' => $result['status']]); - - return success(0, '版本详情', $result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - /** - * Common: 生成小程序推广二维码 - * Author: wu-hui - * Time: 2023/01/03 14:12 - * @return array - */ - public function qrcodeCreate() - { - $cacheName = 'alipay_open_app_qrcode_create_response_' . $this->site_id; - // 缓存操作 - $result = cache($cacheName); - if ($result) { - return $this->success($result); - } else { - // 获取默认门店id - $storeId = (int)Db::name('store') - ->where('site_id', $this->site_id) - ->where('is_default', 1) - ->value('store_id'); - if ($storeId <= 0) $this->error('', '默认门店不存在,请添加后进行操作!'); - $params = [ - 'url_param' => 'pages/index/index',// 访问页面路径 - 'query_param' => 'site_id=' . $this->site_id . '&store_id=' . $storeId,// 小程序的启动参数 - 'describe' => '小程序预览',//对应的二维码描述 - 'color' => '', - 'size' => 'l',// 合成后图片的大小(s -- 8cm, m -- 12cm, l -- 30cm) - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.app.qrcode.create', $params); - $result = $result['alipay_open_app_qrcode_create_response']; - // 返回结果 - if ($result['code'] == 10000) { - cache($cacheName, $result); - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - } - - public function queryTestQrcode($version) - { - - $params['app_version'] = $this->version;//$version; -// (new MinCode($this->site_id))->requestApi('alipay.open.mini.experience.create', $params); - $result = (new MinCode($this->site_id))->requestApi('alipay.open.mini.experience.query', $params); - $result = $result['alipay_open_mini_experience_query_response']; - // 返回结果 - if ($result['code'] == 10000) { - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - - /** - * Common: 登录 —— 获取用户基本信息 - * Author: wu-hui - * Time: 2023/01/05 13:33 - * @param string $code - * @param string $grantType - * @param string $refreshToken - * @return array - */ - public function loginBaseInfo($code = '', $grantType = 'authorization_code', $refreshToken = '') - { - // authorization_code=换取授权令牌access_token;refresh_token=刷新获取新授权令牌。 - $textParams = [ - 'grant_type' => $grantType - ]; - if ($grantType == 'refresh_token') $textParams['refresh_token'] = $refreshToken; - else if ($grantType == 'authorization_code') $textParams['code'] = $code; - // 发起请求 - $result = (new MinCode($this->site_id))->requestApi('alipay.system.oauth.token', [], $textParams); - $result = $result['alipay_system_oauth_token_response'] ?? $result['error_response']; - // 返回结果 - if (array_key_exists('user_id', $result)||array_key_exists('open_id',$result)) { - if(isset($result['open_id'])){ - $result['user_id']=$result['open_id']; - } - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - - /** - * Common: 登录 —— 获取用户详细信息 - * Author: wu-hui - * Time: 2023/01/05 14:04 - * @param $authToken - * @return array - */ - public function loginDetailsInfo($authToken) - { - // 发起请求 - $result = (new MinCode($this->site_id))->requestMemberApi($authToken, 'alipay.user.info.share'); - $result = $result['alipay_user_info_share_response'] ?? $result['error_response']; - // 返回结果 - if ($result['code'] == 10000) { - - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AliPayMember.php b/addon/aliapp/model/AliPayMember.php deleted file mode 100644 index c979985..0000000 --- a/addon/aliapp/model/AliPayMember.php +++ /dev/null @@ -1,183 +0,0 @@ -site_id = $siteId; - } - - - /** - * Common: 小程序成员管理 查询集合 - * Author: wu-hui - * Time: 2022/12/29 18:38 - * @return Db - */ - private function appletMemberCollection($type){ - return Db::name('applet_member') - ->where('site_id',$this->site_id) - ->where('type',$type); - } - - - /** - * Common: 获取成员列表 - * Author: wu-hui - * Time: 2022/12/30 13:51 - * @return array - * @throws \think\db\exception\DbException - */ - public function getList(){ - // 参数获取 - $page = input('page',1); - $pageSize = input('page_size',PAGE_LIST_ROWS); - // 列表获取 - $field = [ - 'id', - 'user_id', - 'nick_name', - 'status', - 'gmt_join', - 'logon_id', - 'gmt_invite', - 'role' - ]; - $result = $this->appletMemberCollection(1) - ->field($field) - ->order(['gmt_join'=>'DESC','gmt_invite'=>'DESC']) - ->paginate(['list_rows' => $pageSize,'page' => $page]); - if($result) { - $result = $result->toArray(); - $list = [ - 'count' => $result['total'], - 'list' => $result['data'], - 'page_count' => $result['last_page'], - ]; - return $this->success($list); - } - - return $this->success(); - } - /** - * Common: 同步成员 - * Author: wu-hui - * Time: 2022/12/30 13:46 - * @param $role - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function synchronizationMember($role){ - $params = ['role' => $role]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.app.members.query',$params); - $result = $result['alipay_open_app_members_query_response']; - if($result['code'] == 10000) { - $list = $result['app_member_info_list'] ?? []; - $hasList = $this->appletMemberCollection(1)->field('id,logon_id')->select(); - $logonIds = $ids = []; - if($hasList){ - $hasList = $hasList->toArray(); - $logonIds = array_column($hasList,'logon_id'); - $ids = array_column($hasList,'id','logon_id'); - } - $insertData = []; - $updateData = []; - foreach($list as $item){ - // 判断:当前用户是 新增加成员 还是 旧的成员 - if(!in_array($item['logon_id'],$logonIds)){ - // 不存在 新增成员 - $insertData[] = [ - 'site_id' => $this->site_id, - 'type' => 1, - 'user_id' => $item['user_id'] ?? '', - 'nick_name' => $item['nick_name'] ?? '', - 'status' => $item['status'] ?? '', - 'gmt_join' => $item['gmt_join'] ?? '', - 'logon_id' => $item['logon_id'] ?? '', - 'gmt_invite' => $item['gmt_invite'] ?? '', - 'role' => $item['role'] ?? '', - ]; - } - else if(in_array($item['logon_id'],$logonIds)){ - // 存在 修改成员 - $updateData[] = [ - 'id' => $ids[$item['logon_id']], - 'nick_name' => $item['nick_name'] ?? '', - 'status' => $item['status'] ?? '', - 'role' => $item['role'] ?? '' - ]; - } - } - Db::name('applet_member')->insertAll($insertData); - (new NewBaseModel(['table_name'=>'applet_member']))->saveAll($updateData); - - return success(0,'同步完成'); - }else{ - return $this->error('',$result['sub_msg']); - } - } - /** - * Common: 添加成员 - * Author: wu-hui - * Time: 2022/12/30 14:27 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function addMember(){ - $info = input('info'); - $params = [ - 'logon_id' => $info['logon_id'], - 'role' => $info['role'], - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.app.members.create',$params); - $result = $result['alipay_open_app_members_create_response']; - if($result['code'] == 10000) { - $this->synchronizationMember($info['role']); - return success(0,'添加成功'); - }else{ - return $this->error('',$result['sub_msg']); - } - } - /** - * Common: 删除成员 - * Author: wu-hui - * Time: 2022/12/30 14:41 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function delMember(){ - $id = input('id'); - $info = Db::name('applet_member')->field('user_id,role')->where('id',$id)->find(); - if(!$info) return $this->error('','不存在的成员!'); - $params = [ - 'user_id' => $info['user_id'], - 'role' => $info['role'], - ]; - $result = (new MinCode($this->site_id))->requestApi('alipay.open.app.members.delete',$params); - $result = $result['alipay_open_app_members_delete_response']; - if($result['code'] == 10000) { - Db::name('applet_member')->where('id',$id)->delete(); - - return success(0,'删除成功'); - }else{ - return $this->error('',$result['sub_msg']); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AliPayMemberCard.php b/addon/aliapp/model/AliPayMemberCard.php deleted file mode 100644 index 6560a36..0000000 --- a/addon/aliapp/model/AliPayMemberCard.php +++ /dev/null @@ -1,31 +0,0 @@ -rsaCheck($param); - if ($rsaCheck && isset($param['notify_type'])) { - Log::write('支付宝回调通知-会员卡:' . $param['notify_type'] . json_encode($param, JSON_UNESCAPED_UNICODE)); - switch ($param['notify_type']) { - case 'alipay.service.check': - echo 'success'; - break; - case 'servicemarket_order_notify': //服务订单通知 - $this->servicemarketOrderNotify($param); - break; - case 'open_app_auth_notify': //服务订单授权通知 - $this->openAppAuthnotify($param); - break; - } - } - } - public function rsaCheck($param) - { - $payModel = new MinCode(); - $res = $payModel->verifySgin($param); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AliPayMessage.php b/addon/aliapp/model/AliPayMessage.php deleted file mode 100644 index 17ecd35..0000000 --- a/addon/aliapp/model/AliPayMessage.php +++ /dev/null @@ -1,703 +0,0 @@ -param = $param; - $this->site_id = $param['site_id']; - $this->merchant_biz_type = $merchant_biz_type; - $this->minCodeModel = new MinCode($this->site_id); - if (isset($param['order_id'])) { - $order_id = $param["order_id"]; - $this->order_info = model('order') - ->getInfo([["order_id", "=", $order_id]], "out_trade_no,order_type,order_no,mobile,member_id,order_name,pay_time,create_time,pay_money,order_money,close_time"); - $this->item_order_list = $this->getGoodsInfo($this->param['order_id'], '');// 商品信息; - } - } - - /*** - * 订单创建同步消息 - * @param $param - * @return void - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function OrderCreateMsg() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'CREATE', $path); - return $res; - } - - /*** - * 支付成功消息 - * @param $param - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function messagePaySuccess() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'PAID', $path); - return $res; - } - - - /** - * 订单发货 - * @param $param - * @return void - */ - public function messageOrderDelivery() - { - - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'IN_DELIVERY', $path); - return $res; - - } - - /*** - * 订单催款 - * @param $param - * @return void - */ - public function messageOrderUrgePayment() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'WAIT_PAY', $path); - return $res; - } - - - /*** - * 退款中 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function MessageOrderRefundinG(){ - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'REFUNDING', $path); - return $res; - - } - - /*** - * 订单完成 - * @param $param - * @return void - */ - public function messageBuyerOrderComplete() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'FINISHED', $path); - return $res; - } - - /*** - * 订单关闭 - * @param $param - * @return void - */ - public function messageOrderClose() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'CLOSED', $path); - return $res; - } - - /*** - * 商家同意退款 - * @return void - */ - public function messageOrderRefundAgree() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'REFUNDED', $path); - return $res; - } - - /** - * 商家拒绝退款 - * @return void - */ - public function messageOrderRefundRefuse() - { - - } - - - /*** - * 订单核销 - * @return void - */ - public function messageOrderVerify() - { - $path = $this->handleUrl(); - $url = urlencode('/pages/index/index'); - $business_info = [ - 'come_again' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}" - ]; - $res = $this->AlipayOrderSyncMsg($business_info, 'REFUNDED', $path); - return $res; - } - - - /*** - * 发送订单消息 - * @param $orderInfo - */ - public function SendAccMessage($orderInfo, $order_scene = '') - { - $order_scene = $orderInfo['order_scene'] ?? $order_scene; - switch ($order_scene) { - case 'cashier': - $business_info = [ - 'consumption_project' => '消费买单', - 'card_balance' => '您的会员余额未消费', - 'consumption_amount' => '本次消费' . $orderInfo['order_money'] . '元', - ]; - $typeStatus = 'CONSUME_S'; - $merchant_biz_type = 'STORED_VALUE_ACCOUNT_N'; - $item_order_list = [ - 'item_name' => '用户买单', - 'ext_info' => [ - [ - 'ext_key' => 'image_material_id', - 'ext_value' => $this->getCacheImageMaterialID('cashier', 'cashier', 'upload/cashier/mbuy.png'), - ] - ] - ]; - $this->AlipayOrderSyncMsg($orderInfo, $business_info, $item_order_list, $typeStatus, $merchant_biz_type); - break; - case 'recharge': - $balance = Db::name('member')->where('member_id', '=', $orderInfo['member_id'])->value('balance'); - $business_info = [ - 'recharge_amount' => '实际支付' . $orderInfo['buy_price'] . '元', - 'consumption_project' => '会员充值', - 'card_balance' => '您的会员余额' . $balance . '元', //会员卡余额 - 'recharge_time' => date('Y-m-d H:i:s', $orderInfo['create_time']), - //'consumption_amount'=>'本次充值'.$orderInfo['buy_price'].'元', - // 'details'=>'会员卡充值赠送'.$orderInfo['face_value'].'元', - ]; - $typeStatus = 'RECHARGE_S'; - $merchant_biz_type = 'STORED_VALUE_ACCOUNT_N'; - $item_order_list = [ - 'item_name' => '会员充值', - 'ext_info' => [ - [ - 'ext_key' => 'image_material_id', - 'ext_value' => $this->getCacheImageMaterialID('cashier', 'cashier', 'upload/cashier/mbuy.png'), - ] - ] - ]; - $orderInfo['order_money'] = $orderInfo['buy_price']; - $orderInfo['out_trade_no'] = $orderInfo['order_no']; - $this->AlipayOrderSyncMsg($orderInfo, $business_info, $item_order_list, $typeStatus, $merchant_biz_type); - break; - case 'reservation': //预约 - $storeInfo = Db::name('store')->where(['store_id' => $orderInfo['store_id']])->cache('storeInfo_' . $orderInfo['store_id'], null, 'alipay_msg')->field('store_name,telphone,address')->find(); - $types = [ - 'wait_confirm' => 'BOOK_SUCCESSFULLY', //待商家确认 - 'wait_to_store' => 'ORDER_CHANGE', //待到到店 - 'cancelled' => 'CLOSED', //服务取消 - 'arrived_store' => 'DELIVERED', //已到店 - 'completed' => 'PAID', //完成 - ]; - $orderInfo = model('reserve')->getInfo(['reserve_id' => $orderInfo['reserve_id']]); - $business_info = [ - 'book_item' => $orderInfo['reserve_item'], //项目名称 - 'address' => $storeInfo['address'], //店铺位置 - 'booking_name' => $orderInfo['reserve_name'], //预约师傅 - 'shop_name' => $storeInfo['store_name'] ?? $this->getSiteName(), - 'shop_phone' => $storeInfo['telphone'], - 'start_time' => '您的预约时间' . date('Y-m-d H:i:s', $orderInfo['reserve_time']), - 'end_time' => date('Y-m-d H:i:s', $orderInfo['reserve_time'] + 3600), - ]; - $typeStatus = $types[$orderInfo['reserve_state']] ?? ''; - $merchant_biz_type = 'TO_SHOP'; - $item_order_list = [ - 'item_name' => $orderInfo['reserve_item'], - 'ext_info' => [ - [ - 'ext_key' => 'image_material_id', - 'ext_value' => $this->getCacheImageMaterialID('cashier', 'cashier', 'upload/cashier/mbuy.png'), - ] - ] - ]; - $orderInfo['out_trade_no'] = $orderInfo['reserve_id']; - $orderInfo['pay_time'] = $orderInfo['create_time']; - $this->AlipayOrderSyncMsg($orderInfo, $business_info, $item_order_list, $typeStatus, $merchant_biz_type); - break; - case 'online': - break; - } - return $this->success(); - } - - - /** - * 发送同步消息 - * @param $orderInfo - * @param $typeStatus - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function AlipayOrderSyncMsg(array $business_info, $typeStatus = 'CONSUME_S', $path = '/pages/index/index') - { - // 参数获取 - $appid = $this->getAppid();// 获取小程序id - $orderInfo = $this->order_info; - $item_order_list = $this->item_order_list; - $merchant_biz_type = $this->merchant_biz_type; - $aliOpenid = $this->getAliOpenId($orderInfo['member_id']); - if ($aliOpenid) { - $siteName = $this->getSiteName(); - $params = [ - 'out_biz_no' => $orderInfo['out_trade_no'],// 外部订单号 - 'buyer_id' => $aliOpenid,// 买家userId - 'amount' => $orderInfo['order_money'] ?? '',// 订单金额,单位为【元】 - 'pay_amount' => $orderInfo['pay_money'] ?? '',// 支付金额,单位为【元】 - 'order_type' => 'SERVICE_ORDER',// 订单类型,新接入商户统一传入SERVICE_ORDER(服务订单) - 'order_create_time' => date('Y-m-d H:i:s', $orderInfo['create_time']),//订单创建时间 当order_type为SERVICE_ORDER时必传 日期 - 'order_modified_time' => date('Y-m-d H:i:s', $orderInfo['create_time']),// 订单修改时间 - 'order_pay_time' => $orderInfo['pay_time'] > 0 ? date('Y-m-d H:i:s', $orderInfo['pay_time']) : '',// 订单支付时间 当pay_channel为非ALIPAY时 且订单状态已流转到“支付”或支付后时,需要将支付时间传入 - 'item_order_list' => $item_order_list, - 'shop_info' => [ - 'name' => $siteName, - ], - 'ext_info' => [ - ['ext_key' => 'tiny_app_id', 'ext_value' => $appid], - ['ext_key' => 'merchant_biz_type', 'ext_value' => $merchant_biz_type], - ['ext_key' => 'merchant_order_status', 'ext_value' => $typeStatus], - ['ext_key' => 'merchant_order_link_page', 'ext_value' => $path], - [ - 'ext_key' => 'business_info', - 'ext_value' => json_encode($business_info) - ] - ] - ]; - if (!$params['amount']) unset($params['amount']); - if (!$params['pay_amount']) unset($params['pay_amount']); - // 发起请求 - $result = $this->minCodeModel->requestApi('alipay.merchant.order.sync', $params, []); - $result = $result['alipay_merchant_order_sync_response']; - if ($result['code'] == 10000) { - return $this->success($result); - } else { - return $this->error('', $result['sub_msg']); - } - } - } - - - /** - * 获取会员openid - * @param $member_id - * @return mixed - */ - public function getAliOpenId($member_id) - { - $aliOpenid = Db::name('member') - ->where(['member_id' => $member_id]) - ->cache('ali_openid_' . $member_id, null, 'alipay_msg') - ->value('ali_openid'); - return $aliOpenid; - } - - /** - * 获取站点名称 - * @return mixed - */ - public function getSiteName() - { - $siteName = Db::name('site') - ->where('site_id', $this->site_id) - ->cache('ali_site_id_' . $this->site_id, null, 'alipay_msg') - ->value('site_name'); - return $siteName; - } - - /** - * Common: 订单中心 —— 获取小程序id - * Author: wu-hui - * Time: 2023/01/04 16:15 - * @return mixed - */ - public function getAppid() - { - return Db::name('uni_account') - ->cache('aliapp_appid_key_' . $this->site_id, null, 'alipay_msg') - ->where('site_id', $this->site_id) - ->where('app_type', '=', 'aliapp') - ->value('appid'); - } - - /*** - * 获取缓存ID - * @param $type - * @param $imgName - * @param $path - * @return mixed|string - */ - public function getCacheImageMaterialID($type, $imgName, $path) - { - if ($Images = cache('material' . $type . $this->site_id)) { - return $Images['image_id']; - } else { - try { - $upImages = $this->minCodeModel->imageUpload($imgName, img($path), true); - $response = $upImages['alipay_offline_material_image_upload_response']; - if ($response['code'] == 10000) { - cache('material' . $type . $this->site_id, $response, null, 'ImageMaterialId'); - return $response['image_id']; - } else { - return 'A*iEHnTLFEG5wAAAAAAAAAAAAABKd2AQ'; - } - } catch (Exception $e) { - Log::write('消息发送 - 图片id获取失败:' . $e->getMessage()); - return 'A*iEHnTLFEG5wAAAAAAAAAAAAABKd2AQ'; - } - } - } - - /** - * Common: 订单中心 —— 获取会员卡信息 - * Author: wu-hui - * Time: 2023/01/04 16:44 - * @param $orderId - * @return array|mixed|Db|\think\Model|null - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getCardInfo($orderId) - { - return Db::name('member_goods_card') - ->field('card_id,end_time') - ->where('order_id', $orderId) - ->find(); - } - - /** - * Common: 订单中心 —— 获取商品信息 - * Author: wu-hui - * Time: 2023/01/04 16:28 - * @param $orderId - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getGoodsInfo($orderId, $scene = '') - { - // MERCHANT_SECURITIES=商家核销;STORED_VALUE_ACCOUNT=储值动账(到店版) - $data = []; - $list = Db::name('order_goods') - ->field('sku_id,num,price,sku_name,sku_image') - ->cache(true, null, $orderId . 'alipayGetGoodsInfo') - ->where('order_id', $orderId) - ->select()->toArray(); - if ($list) { - $url = urlencode('/pages_market/order/detail?order_id=' . $orderId); - foreach ($list as $item) { - $data[] = [ - 'quantity' => $item['num'], - 'unit_price' => $item['price'], - 'sku_id' => $item['sku_id'], - 'item_name' => $item['sku_name'], - 'ext_info' => [ - [ - "ext_key" => "image_material_id", - "ext_value" => $this->uploadImage($item) - ], - [ - 'ext_key' => 'merchant_item_link_page', - 'ext_value' => "alipays://platformapi/startapp?appId={$this->getAppid()}&page={$url}", - ] - ] - ]; - } - } - switch ($scene) { - case 'MERCHANT_SECURITIES': - break; // 商家核销 - case 'STORED_VALUE_ACCOUNT': - break;// 储值动账(到店版) - } - return $data; - } - - - /** - * 处理订单链接 - * @param $order_type - * @param $order_id - * @return string - */ - public function handleUrl() - { - switch ($this->order_info['order_type']) { - case 2: - return '/pages_market/order/detail_pickup?order_id=' . $this->param['order_id']; - case 3: - return '/pages_market/order/detail_local_delivery?order_id=' . $this->param['order_id']; - case 4: - return '/pages_tool/order/detail_virtual?order_id=' . $this->param['order_id']; - default: - return '/pages_market/order/detail?order_id=' . $this->param['order_id']; - } - } - - /** - * Common: 订单中心 —— 商品图片上传 - * Author: wu-hui - * Time: 2023/04/12 14:36 - * @param $item - * @return mixed|string - */ - public function uploadImage($item) - { - // 图片上传支付宝 ///image_id A*iEHnTLFEG5wAAAAAAAAAAAAABKd2AQ - $imgUploadResult = $this->minCodeModel->imageUpload($item['sku_name'], img($item['sku_image']), true); - return $imgUploadResult['alipay_offline_material_image_upload_response']['image_id'] ?? 'A*iEHnTLFEG5wAAAAAAAAAAAAABKd2AQ'; - } - - - /** - * Common: 订阅消息发送 —— 开始 - * Author: wu-hui - * Time: 2023/01/10 16:12 - * @param $uid - * @param $keywords - * @param array $params - * @param string $page - * @return array - */ - public function sendMessage($uid, $keywords, $params = [], $page = 'pages/index/index') - { - try { - // 通过用户user_id - $userId = Db::name('member')->where('member_id', $uid)->value('ali_openid'); - if (!$userId) return $this->error('', '用户不存在支付宝小程序user_id!'); - // 判断:用户是否订阅当前消息 - $subscribeInfo = $this->userIsSubscribeMessage($uid, $keywords); - // 消息发送 - $sendData = $this->getSendData($keywords, $params); - $params = [ - 'to_user_id' => $userId, - 'user_template_id' => $subscribeInfo['template_id'], - 'page' => $page, - 'data' => json_encode($sendData, JSON_UNESCAPED_UNICODE), - ]; - // 发起请求 - $result = (new MinCode($this->site_id))->requestApi('alipay.open.app.mini.templatemessage.send', $params, []); - $result = $result['alipay_open_app_mini_templatemessage_send_response']; - if ($result['code'] == 10000) { - // 发送成功后的处理 - Db::name('message_form_id')->where($subscribeInfo)->delete();// 删除记录 - // 发送记录 - $this->sendLog($keywords, $params, $result, 1); - return $this->success($result); - } else { - // 发送记录 - $this->sendLog($keywords, $params, $result, 0); - return $this->error('', $result['sub_msg']); - } - } catch (Exception $e) { - // 发送记录 - $this->sendLog($keywords, $params, ['error_msg' => $e->getMessage()], 0); - return $this->error('', $e->getMessage()); - } - } - - /** - * Common: 订阅消息发送 —— 判断:用户是否订阅当前消息 - * Author: wu-hui - * Time: 2023/01/10 15:13 - * @param $uid - * @param $keywords - * @return array|mixed|Db|\think\Model - * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function userIsSubscribeMessage($uid, $keywords) - { - // 获取模板id - $templateId = Db::name('message') - ->where('site_id', $this->site_id) - ->where('keywords', $keywords) - ->where('aliapp_is_open', 1) - ->value('aliapp_template_id'); - if (!$templateId) throw new Exception('当前模板消息未开启或未设置!'); - // 获取用户订阅消息 - $subscribeInfo = Db::name('message_form_id') - ->where('template_id', $templateId) - ->where('uid', $uid) - ->where('type', 'aliapp') - ->order('create_time', 'ASC') - ->find(); - if (!$subscribeInfo) throw new Exception('当前用户未订阅该信息!'); - return $subscribeInfo; - } - - /** - * Common: 订阅消息发送 —— 获取发送信息 - * Author: wu-hui - * Time: 2023/01/10 15:40 - * @param $keywords - * @param $params - * @return mixed - * @throws Exception - */ - private function getSendData($keywords, $params) - { - // 键名转驼峰 方法名称 - $nameArr = array_map(function ($item) { - return ucwords(strtolower($item)); - }, explode('_', $keywords)); - $classList = get_class_methods(self::class); - $className = 'message' . implode($nameArr); - if (in_array($className, $classList)) return $this->$className($params); - else throw new Exception('未获取发送信息!'); - } - - /** - * Common: 订阅消息发送 —— 发送记录 - * Author: wu-hui - * Time: 2023/01/10 16:10 - * @param $keywords - * @param $params - * @param $sendResult - * @param $isSuccess - * @return int|string - */ - private function sendLog($keywords, $params, $sendResult, $isSuccess) - { - $sendLog = [ - 'site_id' => $this->site_id, - 'keywords' => $keywords, - 'message_type' => 'aliapp', - 'addon' => '', - 'title' => '', - 'message_json' => json_encode($params, JSON_UNESCAPED_UNICODE), - 'create_time' => time(), - 'send_time' => time(), - 'send_log' => json_encode($sendResult, JSON_UNESCAPED_UNICODE), - 'is_success' => $isSuccess, - ]; - return Db::name('message_send_log')->insert($sendLog); - } - - /** - * Common: 订阅消息发送信息 —— 权益即将过期通知 - * Author: wu-hui - * Time: 2023/01/10 15:40 - * @param $params - * @return array[] - */ - private function messageInterestExpirationNotice($params) - { - return [ - 'keyword1' => ['value' => $params['store_name']], // 商家名称 - 'keyword2' => ['value' => $params['surplus']],// 剩余次数 - 'keyword3' => ['value' => $params['content']],// 优惠内容 - ]; - } - - /** - * Common: 订阅消息发送信息 —— 服务开通成功提醒 - * Author: wu-hui - * Time: 2023/01/10 15:40 - * @param $params - * @return array[] - */ - private function messageServiceOpenedSuccess($params) - { - return [ - 'keyword1' => ['value' => $params['end_time']], // 到期时间 日期:2022年1月18日 - 'keyword2' => ['value' => $params['nickname']],// 姓名 - 'keyword3' => ['value' => $params['start_time']],// 开通时间 日期:2022年1月18日 - 'keyword4' => ['value' => $params['content']],// 服务项目 - ]; - } - - /** - * Common: 订阅消息发送信息 —— 核销提醒 - * Author: wu-hui - * Time: 2023/01/10 15:40 - * @param $params - * @return array[] - */ - private function messageVerify($params) - { - return [ - 'keyword1' => ['value' => $params['goods_name']], // 核销产品 - 'keyword2' => ['value' => $params['store_name']],// 核销商户 - 'keyword3' => ['value' => $params['start_time']],// 核销时间 日期:2022年1月18日 - ]; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AliPaySubLedger.php b/addon/aliapp/model/AliPaySubLedger.php deleted file mode 100644 index 8a39b22..0000000 --- a/addon/aliapp/model/AliPaySubLedger.php +++ /dev/null @@ -1,394 +0,0 @@ -site_id = (int)$siteId; - } - - /** - * Common: 分账关系绑定 - * Author: wu-hui - * Time: 2023/01/29 16:06 - * @param $websiteId - * @return array - * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function relationBind($websiteId){ - // 请求参数获取 - $params = $this->relationParams($websiteId); - $textParams = []; - // 发起请求 - $result = (new OpenPay($this->site_id))->requestApi('alipay.trade.royalty.relation.bind', $params,$textParams); - $result = $result['alipay_trade_royalty_relation_bind_response']; - - if($result['code'] == 10000) return $this->success(); - else throw new Exception($result['sub_msg']); - } - /** - * Common: 分账关系解绑 - * Author: wu-hui - * Time: 2023/01/29 16:18 - * @param $websiteId - * @return array - * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function relationUnbind($websiteId){ - // 请求参数获取 - $params = $this->relationParams($websiteId); - $textParams = []; - // 发起请求 - $result = (new OpenPay($this->site_id))->requestApi('alipay.trade.royalty.relation.unbind', $params,$textParams); - $result = $result['alipay_trade_royalty_relation_unbind_response']; - - if($result['code'] == 10000) return $this->success(); - else throw new Exception($result['sub_msg']); - } - /** - * Common: 分账关系查询 - * Author: wu-hui - * Time: 2023/02/01 11:22 - * @return array - * @throws Exception - */ - public function relationBatchQuery(){ - // 请求参数获取 - $params = [ - 'page_num' => 1, - 'page_size' => 100, - 'out_request_no' => $this->outRequestNo(0,'BDGX') - ]; - $textParams = []; - // 发起请求 - $result = (new OpenPay($this->site_id))->requestApi('alipay.trade.royalty.relation.batchquery', $params,$textParams); - $result = $result['alipay_trade_royalty_relation_batchquery_response']; - - if($result['code'] == 10000) return $this->success($result); - else throw new Exception($result['sub_msg']); - } - /** - * Common: 分账关系绑定|解绑 参数获取 - * Author: wu-hui - * Time: 2023/01/29 15:47 - * @param $websiteId - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - private function relationParams($websiteId){ - // 合伙人信息获取 - $info = Db::name('website')->field('alipay_account,web_contacts')->where('id',$websiteId)->find(); - // 店铺名称获取 - $siteInfo = Db::name('site')->field('site_name,username')->where('site_id',$this->site_id)->find(); - $siteName = $siteInfo['site_name'] ? : $siteInfo['username']; - return [ - 'receiver_list' => [ - 'type' => 'loginName',// 分账接收方方类型:loginName表示是支付宝登录号 - 'account' => $info['alipay_account'],// 分账接收方账号:当分账方类型是loginName时,本参数为用户的支付宝登录号 - //'account_open_id' => '',// 分账接收方openId - 'name' => $info['web_contacts'],// 当分账方类型是loginName时,本参数必传。 - 'memo' => "[{$siteName}]分账给[{$info['web_contacts']}]",// 分账关系描述 - 'login_name' => $info['alipay_account'],// 作为查询返回结果 - 'bind_login_name' => $info['alipay_account'],// 作为查询返回结果 - ], - 'out_request_no' => $this->outRequestNo($websiteId) - ]; - } - /** - * Common: 生成外部唯一请求号 - * Author: wu-hui - * Time: 2023/01/29 15:30 - * @param $websiteId - * @param string $prefix - * @return string - */ - private function outRequestNo($websiteId,$prefix = 'SL'){ - // 基础内容 - $timeStr = $prefix.date('ymdHis').'S'.$this->site_id.'W'.$websiteId; - // 保证不重复 偏移操作 - $cacheName = $this->site_id.'_'.$websiteId.'_'.$timeStr; - $maxNo = (int)cache($cacheName); - $order_no = $timeStr.'N'.$maxNo; - cache($cacheName,++$maxNo,5); - - return $order_no; - } - /** - * Common: 分账 —— 确认结算 - * Author: wu-hui - * Time: 2023/02/01 15:29 - * @param int $orderId - * @return false|void - */ - public function settleConfirm(int $orderId){ - try{ - // 获取当前订单状态 - $tradeQuery = $this->tradeQuery($orderId)['data']; - if($tradeQuery['trade_status'] != 'TRADE_SUCCESS') throw new Exception('当前订单不允许分账!订单状态:'.$tradeQuery['trade_status']); - if($orderId <= 0) throw new Exception("订单id错误 {$orderId}"); - // 获取订单信息 - $orderInfo = $this->getOrderInfo($orderId); - // 获取所有需要分红的合伙人信息 - $siteWebsite = (new SiteWebsite())->getWholeSiteWebsiteList($orderInfo['site_id'])['data']; - if(!$siteWebsite) throw new Exception("没有合伙人;订单id: {$orderId}"); - // 生成每个合伙人的分账信息 - $insertData = []; - $time = time(); - foreach($siteWebsite as $siteWebsiteInfo){ - $insertData[] = [ - 'site_id' => $orderInfo['site_id'], - 'order_id' => $orderInfo['order_id'],// 订单id - 'trade_no' => $orderInfo['trade_no'],// 支付宝订单号 - 'trans_in' => $siteWebsiteInfo['alipay_account'],// 收入方账户 - 'amount' => sprintf("%.2f",($orderInfo['pay_money'] * ($siteWebsiteInfo['rate'] / 100))),// 添加时间 - 'website_id' => $siteWebsiteInfo['website_id'], - 'create_time' => $time - ]; - } - Db::name('sub_ledger')->insertAll($insertData); - // 添加计划任务 - $cron_model = new Cron(); - $cron_model->addCron(1, 0, '分账确认结算', 'SettleConfirmSubLedger', strtotime('+1 minute', time()), $orderInfo['order_id']); - - - /* - // 配置信息 - $params = [ - 'out_request_no' => $this->outRequestNo(0,'JS'),//确认结算请求流水号,开发者自行生成并保证唯一性,作为业务幂等性控制 - 'trade_no' => $orderInfo['trade_no'] ?? 0,// 支付宝交易号 - 'settle_info' => [ - 'settle_detail_infos' => [ - [ - // cardAliasNo:结算收款方的银行卡编号;userId:表示是支付宝账号对应的支付宝唯一用户号;loginName:表示是支付宝登录号;defaultSettle:表示结算到商户进件时设置的默认结算账号,结算主体为门店时不支持传defaultSettle; - 'trans_in_type' => 'defaultSettle', - // 结算收款方。当结算收款方类型是cardAliasNo时,本参数为用户在支付宝绑定的卡编号;结算收款方类型是userId时,本参数为用户的支付宝账号对应的支付宝唯一用户号,以2088开头的纯16位数字;当结算收款方类型是loginName时,本参数为用户的支付宝登录号;当结算收款方类型是defaultSettle时,本参数不能传值,保持为空。 - 'trans_in' => '', - // 结算汇总维度,按照这个维度汇总成批次结算,由商户指定。目前需要和结算收款方账户类型为cardAliasNo配合使用 - //'summary_dimension' => '', - // 结算主体标识。当结算主体类型为SecondMerchant时,为二级商户的SecondMerchantID;当结算主体类型为Store时,为门店的外标。 - //'settle_entity_id' => $payShopInfo['zmalipay_value']['smid'], - // 结算主体类型。二级商户:SecondMerchant;商户或者直连商户门店:Store - //'settle_entity_type' => 'SecondMerchant', - // 结算的金额,单位为元。在创建订单和支付接口时必须和交易 金额相同。在结算确认接口时必须等于交易金额减去已退款金额。直付通账期模式下,如使用部分结算能力、传递了actual_amount字段,则忽略本字段的校验、可不传。 - //'amount' => 0.1,//$orderInfo['pay_money'] ?? 0, - // 仅在直付通账期模式场景下,单笔交易需要分多次发起部分确认结算时使用,表示本次确认结算的实际结算金额。传递本字段后,原amount字段不再生效,结算金额以本字段为准。 - 'actual_amount' => $orderInfo['pay_money'] ?? 0, - ] - ], - ], - 'extend_params' => [ - 'royalty_freeze' => 'true',// 是否进行资金冻结,用于后续分账,true表示冻结,false或不传表示不冻结 - ], - ]; - // 发起请求 - $result = (new OpenPay())->requestApi('alipay.trade.settle.confirm', $params, []); - - $result = $result['alipay_trade_settle_confirm_response']; - if($result['code'] == 10000) return $this->success(); - else throw new Exception($result['sub_msg']); - */ - } - catch(Exception $e){ - Log::write("分账 - 确认结算:".$e->getMessage()); - return false; - } - } - /** - * Common: 分账 —— 分账请求 - * Author: wu-hui - * Time: 2023/02/01 17:08 - * @param $orderId - * @return array|false - * @throws \think\db\exception\DbException - */ - public function orderSettle($orderId){ - $time = time(); - try{ - // 获取所有分账信息 - $subLedgerList = Db::name('sub_ledger') - ->field(['trade_no','trans_in','amount']) - ->where('order_id',$orderId) - ->select(); - if($subLedgerList) $subLedgerList = $subLedgerList->toArray(); - else throw new Exception('不存在分账信息!'); - // 基本参数 - $outRequestNo = $this->outRequestNo(0,'FZ');//结算请求流水号 - $tradeNo = array_column($subLedgerList,'trade_no')[0]; - // 循环生成分账信息 - $royaltyParameters = []; - foreach($subLedgerList as $subLedgerInfo){ - $royaltyParameters[] = [ - //'royalty_type' => 'transfer',//分账类型:普通分账为:transfer;补差为:replenish;为空默认为分账transfer; - //'trans_out' => 'zoomtk@126.com',// 支出方账户 - //'trans_out_type' => 'loginName',// 支出方账户类型 - 'trans_in_type' => 'loginName',// 收入方账户类型 - 'trans_in' => $subLedgerInfo['trans_in'],// 收入方账户 - 'amount' => $subLedgerInfo['amount'],// 分账的金额,单位为元 - 'desc' => "订单[{$tradeNo}]的分账金额",// 分账描述 - //'royalty_scene' => '达人佣金',// 可选值:达人佣金、平台服务费、技术服务费、其他 - //'trans_in_name' => '张志伟',// 分账收款方姓名,上送则进行姓名与支付宝账号的一致性校验,校验不一致则分账失败。不上送则不进行姓名校验 - ]; - } - // 参数配置 - $params = [ - 'out_request_no' => $outRequestNo,//结算请求流水号 - 'trade_no' => $tradeNo,// 支付宝交易订单号 - 'royalty_parameters' => $royaltyParameters, - 'extend_params' => [ - // 冻结分账场景下生效,其他场景传入无效。代表该交易分账是否完结,可选值:true/false, - // 不传默认为false。true:代表分账完结,则本次分账处理完成后会把该笔交易的剩余冻结金额全额解冻。false:代表分账未完结。 - 'royalty_finish' => 'true', - ], - 'royalty_mode' => 'sync',// 分账模式,目前有两种分账同步执行sync,分账异步执行async,不传默认同步执行 - ]; - // 发起请求 - $result = (new OpenPay())->requestApi('alipay.trade.order.settle',$params,[]); - Log::write('支付回调 - 分账 —— 分账请求:'.json_encode($result, JSON_UNESCAPED_UNICODE)); - - //debug([$params,$result]); - $result = $result['alipay_trade_order_settle_response']; - if($result['code'] == 10000) { - Db::name('sub_ledger') - ->where('order_id',$orderId) - ->update(['request_time'=>$time,'request_date'=>date('Y-m-d H:i:s',$time),'request_result'=>'成功']); - return $this->success(); - } - else throw new Exception($result['sub_msg']); - } - catch(Exception $e){ - // 记录失败信息 - Db::name('sub_ledger') - ->where('order_id',$orderId) - ->update(['request_time'=>$time,'request_date'=>date('Y-m-d H:i:s',$time),'request_result'=>$e->getMessage()]); - - Log::write("分账 - 分账请求:".$e->getMessage()); - return false; - } - } - /** - * Common: 支付宝交易查询 - * Author: wu-hui - * Time: 2023/01/31 16:49 - * @param $orderId - * @return array - * @throws Exception - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function tradeQuery($orderId){ - $cacheName = 'trade_query_'.$orderId; - $cacheResult = cache($cacheName); - if($cacheResult){ - - return $this->success(json_decode($cacheResult,true)); - } - else{ - // 判断:订单id是否有效 - if($orderId <= 0) throw new Exception("订单id错误 {$orderId}"); - // 获取订单信息 - $orderInfo = $this->getOrderInfo($orderId); - // 配置信息 - $params = [ - 'out_trade_no' => $orderInfo['order_no'],//订单支付时传入的商户订单号,和支付宝交易号不能同时为空。 - 'trade_no' => $orderInfo['trade_no'] ?? 0,// 支付宝交易号 - // 查询选项,商户传入该参数可定制本接口同步响应额外返回的信息字段,数组格式。支持枚举如下: - // trade_settle_info:返回的交易结算信息,包含分账、补差等信息; - // fund_bill_list:交易支付使用的资金渠道; - // voucher_detail_list:交易支付时使用的所有优惠券信息; - // discount_goods_detail:交易支付所使用的单品券优惠的商品优惠信息; - // mdiscount_amount:商家优惠金额; - //'query_options' => [] - ]; - // 发起请求 - $result = (new OpenPay())->requestApi('alipay.trade.query',$params,[]); - $result = $result['alipay_trade_query_response']; - if($result['code'] == 10000){ - cache($cacheName,json_encode($result),3600); - return $this->success($result); - } - else throw new Exception($result['sub_msg']); - } - } - - - /** - * Common: 获取订单信息 - * Author: wu-hui - * Time: 2023/01/30 9:59 - * @param $orderId - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getOrderInfo($orderId){ - $field = [ - 'o.order_id', - 'o.order_no', - 'p.pay_money', - 'p.trade_no', - 'p.pay_time', - 'p.site_id', - ]; - $orderInfo = Db::name('order') - ->alias('o') - ->join('pay p','o.out_trade_no = p.out_trade_no','left') - ->field($field) - ->where('o.order_id',$orderId) - ->find(); - // 判断:订单状态 - if(($orderInfo['pay_time'] ?? 0) <= 0) throw new Exception('订单未支付-'.$orderId); - // 修改site_id - if($orderInfo['site_id'] != $this->site_id) $this->site_id = (int)$orderInfo['site_id']; - - return $orderInfo ?? []; - } - /** - * Common: 获取直通商户信息 - * Author: wu-hui - * Time: 2023/01/30 11:45 - * @return array|mixed|Db|\think\Model - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getPayShopInfo(){ - $info = (array)Db::name('pay_shop') - ->field('shop_id,merchant_name,contacts_name,merchant_smid,zmalipay_value') - ->where('site_id',$this->site_id) - ->find(); - if(!$info) throw new Exception('直通商户信息不存在!'); - if($info) $info['zmalipay_value'] = json_decode($info['zmalipay_value'],true); - if(!$info['zmalipay_value'] || !$info['zmalipay_value']['smid']) throw new Exception('直通商户信息不全!'); - - return $info ?? []; - } - - - -} \ No newline at end of file diff --git a/addon/aliapp/model/Aliapp.php b/addon/aliapp/model/Aliapp.php deleted file mode 100644 index ce21fe1..0000000 --- a/addon/aliapp/model/Aliapp.php +++ /dev/null @@ -1,61 +0,0 @@ -checkPath($param['qrcode_path']); - if ($checkpath_result["code"] != 0) return $checkpath_result; - $urlParam = ''; - if (!empty($param['data'])) { - foreach ($param['data'] as $key => $value) { - if ($urlParam == '') $urlParam .= '?' . $key . '=' . $value; - else $urlParam .= '&' . $key . '=' . $value; - } - } - $param['appId'] = model('uni_account')->getInfo([['site_id', '=', $param['site_id']], ['app_type', '=', 'aliapp']])['appid']; - $domain = 'alipays://platformapi/startapp?appId=' . $param['appId'] . '&page='; - $alipays_url = $domain . $param['page'] . urlencode($urlParam); - $url = 'https://ds.alipay.com/?scheme=' . urlencode($alipays_url); - $filename = $param['qrcode_path'] . '/' . $param['qrcode_name'] . '_' . $param['appId'] . '_' . $param['app_type'] . '.png'; - QRcodeExtend::png($alipays_url, $filename, 'L', 4, 1); - return $this->success(['path' => $filename, 'url' => $url, 'alipays' => $alipays_url]); - } catch (\Exception $e) { - return $this->error('', $e->getMessage()); - } - } - - /** - * 校验目录是否可写 - * @param unknown $path - * @return multitype:number unknown |multitype:unknown - */ - private function checkPath($path) - { - if (is_dir($path) || mkdir($path, intval('0755', 8), true)) { - return $this->success(); - } - return $this->error('', "directory {$path} creation failed"); - } -} diff --git a/addon/aliapp/model/AppletRelease.php b/addon/aliapp/model/AppletRelease.php deleted file mode 100644 index 144bb92..0000000 --- a/addon/aliapp/model/AppletRelease.php +++ /dev/null @@ -1,100 +0,0 @@ - '构建排队中', - 1 => '正在构建', - 2 => '构建成功', - 3 => '构建失败', - 5 => '构建超时', - 6 => '版本创建成功', - ]; - // 支付宝小程序 状态 - protected $versionStatus = [ - 'INIT' => '开发中', - 'AUDITING' => '审核中', - 'AUDIT_REJECT' => '审核驳回', - 'WAIT_RELEASE' => '待上架', - 'BASE_AUDIT_PASS' => '准入不可营销', - 'GRAY' => '灰度中', - 'RELEASE' => '已上架', - 'OFFLINE' => '已下架', - 'AUDIT_OFFLINE' => '已下架', - ]; - - public function __construct($siteId){ - $this->site_id = $siteId; - } - - - /** - * Common: 获取小程序发布记录 - * Author: wu-hui - * Time: 2022/12/29 17:04 - * @return array - * @throws \think\db\exception\DbException - */ - public function getList(){ - // 参数获取 - $page = input('page',1); - $pageSize = input('page_size',PAGE_LIST_ROWS); - $aliPayAppletModel = new AliPayApplet($this->site_id); - // 列表获取 - $field = [ - 'id', - 'version', - 'ali_create_status', - 'is_experience_version', - 'version_status', - 'create_time', - 'audit_reason' - ]; - $result = Db::name('applet_release') - ->field($field) - ->where('site_id',$this->site_id) - ->where('type',1) - ->order('id','desc') - ->paginate(['list_rows' => $pageSize,'page' => $page]); - if($result) { - $result = $result->toArray(); - try{ - $aliCreateStatus = $this->aliCreateStatus; - $versionStatus = $this->versionStatus; - $newestVersion = $aliPayAppletModel->newestVersion(); - // 循环处理信息 - $list = $result['data'] ?? []; - foreach($list as &$item){ - // 获取构建状态 - if(in_array($item['ali_create_status'],[0,1])) $item['ali_create_status'] = (int)$aliPayAppletModel->versionBuildQuery($item['version'],$item['id']); - $item['ali_create_status_text'] = $aliCreateStatus[$item['ali_create_status']]; - // 获取状态 - if($item['version_status']) $item['version_status_text'] = $versionStatus[$item['version_status']]; - // 判断当前版本是否为最新版本 - $item['is_newest_version'] = false; - if($item['version'] == $newestVersion) $item['is_newest_version'] = true; - } - // 获取版本信息 - $list = [ - 'count' => $result['total'], - 'list' => $list, - 'page_count' => $result['last_page'], - ]; - return $this->success($list); - }catch(\Exception $e){ - return $this->error('',$e->getMessage()); - } - } - return $this->success(); - } -} \ No newline at end of file diff --git a/addon/aliapp/model/AuthNotify.php b/addon/aliapp/model/AuthNotify.php deleted file mode 100644 index fe3aa79..0000000 --- a/addon/aliapp/model/AuthNotify.php +++ /dev/null @@ -1,279 +0,0 @@ -rsaCheck($param); - if ($rsaCheck && isset($param['notify_type'])) { - switch ($param['notify_type']) { - case 'alipay.service.check': - echo 'success'; - break; - case 'servicemarket_order_notify': //服务订单通知 - $this->servicemarketOrderNotify($param); - break; - case 'open_app_auth_notify': //授权通知 - $this->openAppAuthnotify($param); - break; - } - } - } - - /*** - * 授权通知处理 - * @param $param - */ - public function openAppAuthnotify($param) - { - $authInfo = json_decode($param['biz_content'], true); - $detail = $authInfo['detail']; - $user_id = $detail['user_id']; - $data = [ - 'original_id' => $user_id, - 'type' => 'aliapp', - 'auth_value' => json_encode($detail), - 'update_time' => time(), - ]; - $where = [ - ['apps_id', '=', $detail['auth_app_id']] - ]; - Db::name('cloud_order')->where($where)->update($data); - if (isset($param['status']) && $param['status'] == 'execute_auth') { - $cloudOrder = Db::name('cloud_order')->where($where)->field('site_id,ag_site_id')->find(); - if ($cloudOrder) { - $this->setAlipayConfig($cloudOrder['site_id'], $cloudOrder['ag_site_id'], $detail); - } else if (isset($authInfo['notify_context']['trigger_context']['out_biz_no'])) { //小程序新注册授权 - $out_biz_no = $authInfo['notify_context']['trigger_context']['out_biz_no'] ?? ''; - if ($out_biz_no) { - $bw = [ - 'business_code' => $out_biz_no, - 'app_type' => 'aliapp', - ]; - $applet = Db::name('applet_reg')->where($bw)->field('site_id,ag_site_id')->find(); - if ($applet) { - $this->setAlipayConfig($applet['site_id'], $applet['ag_site_id'], $detail); - } - } - } - } - echo 'success'; - } - - /*** - * 用户小程序订购 - */ - public function servicemarketOrderNotify($param) - { - $user_id = $param['merchant_pid']; - $site_id = ''; - $ag_site_id = 1; - if (isset($param['isv_ticket'])) { - $reg = model('applet_reg')->getInfo(['business_code' => $param['isv_ticket'], 'app_type' => 'aliapp'], 'site_id,ag_site_id,contact_phone'); - if ($reg) { - $site_id = $reg['site_id']; - $ag_site_id = $reg['ag_site_id']; - if (!isset($param['phone'])) { - $param['phone'] = $reg['contact_phone']; - } - } - $param['ag_site_id'] = $ag_site_id; - $this->upDateMinireg($param); - } - $data = [ - 'site_id' => $site_id, - 'ag_site_id' => $ag_site_id, - 'goods_name' => $param['title'], - 'cloud_goods_id' => $param['item_code'], - 'order_id' => $param['commodity_order_id'], - 'third_order_id' => $param['commodity_order_id'], - 'original_id' => $user_id, - 'type' => 'aliapp', - 'pay_status' => 1, - 'money' => $param['total_price'], - 'contact_name' => $param['contactor'], - 'mobile' => $param['phone'], - 'raw_data' => json_encode($param), - 'update_time' => time(), - 'apps_id' => $param['consumer_miniAppId'], - ]; - $where = [ - 'original_id' => $user_id, - 'third_order_id' => $param['commodity_order_id'], - ]; - try { - if (!$site_id) { - unset($data['site_id']); - if ($data['money'] > 0) { - $data['is_try'] = 0; - } else { - $data['is_try'] = 1; - $data['expire_time'] = $param['period_day']??7; - } - $shopInfo = $this->createShop($data); //创建店铺 - if ($shopInfo['data']['code'] == 0) { - $data['site_id'] = $shopInfo['data']['data']; - } else { - $data['site_id'] = Db::name('site')->where(['username' => $data['mobile']])->value('site_id'); - } - } - $info = Db::name('cloud_order')->where($where)->find(); - if ($info) { - Db::name('cloud_order')->where($where)->update($data); - } else { - $data['create_time'] = time(); - Db::name('cloud_order')->insert($data); - } - echo 'success'; - } catch (Exception $e) { - echo 'success'; - } - } - - - /*** - * 更新注册信息 - * @param $param - * @return void - */ - public function upDateMinireg($param) - { - if (isset($param['isv_ticket'])) { - try { - $data['original_id'] = $param['merchant_pid']; - $data['appid'] = $param['consumer_miniAppId']; - $data['app_type'] = 'aliapp'; - $data['create_time'] = strtotime($param['timestamp']); - $data['update_time'] = time(); - $data['status'] = 'SUCCESS'; - $data['reg_fee'] = model('website')->getValue(['site_id' => $param['ag_site_id']], 'appreg_rate'); - model('applet_reg')->update($data, ['business_code' => $param['isv_ticket'], 'app_type' => 'aliapp']); - } catch (Exception $e) { - - } - } - } - - /*** - * 设置站点授权信息 - * @param $site_id - * @param $ag_site_id - * @param $detail - * @return int - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function setAlipayConfig($site_id, $ag_site_id = 0, $detail) - { - - $paydata = [ - 'line_type' => 'auth', - 'app_type' => 'aliapp', - 'site_id' => $site_id, - 'ag_site_id' => $ag_site_id, - 'appid' => $detail['auth_app_id'], - 'appsecret' => '', - 'token' => '', - 'app_name' => '', - 'head_img' => '', - 'qrcode' => '', - 'account' => $detail['user_id'], - 'alipay_public' => '', - 'private_key' => '', - 'app_auth_token' => $detail['app_auth_token'], - 'app_refresh_token' => $detail['app_refresh_token'], - 'app_original' => $detail['user_id'], - 'original_values' => $detail, - ]; - if ($site_id) { - $minapp = new Config(); - $minapp->setAlipayConfig($detail['auth_app_id'], $paydata, $site_id, $paydata['app_original']); - event('MiniappAuthInfo', $paydata); - } - return 1; - } - - /*** - * 云订单创建店铺 - * @param $data - * @return array - */ - public function createShop($data) - { - //店铺信息 - $shop_data = [ - 'site_name' => $data['contact_name'], //店铺名称 - 'contacts_name' => $data['contact_name'], //联系人 - 'contacts_mobile' => $data['mobile'], //联系电话 - 'agent_id' => $data['ag_site_id'], //所属代理 - 'group_id' => 1, - 'expire_time' => $data['expire_time']??0, - 'fee_commission' => 2, - 'is_try' => $data['is_try'], //是否体验用户 - ]; - $username = $data['mobile'] ?? $data['original_id']; - $mobile=''; - if (preg_match("/^1[345789]\d{9}$/", $data['mobile'])) { - $_see_password =substr($data['mobile'], -6); - $mobile=$data['mobile']; - $password = data_md5($_see_password); - } else { - $_see_password ='888888'; - $password = data_md5($_see_password); - } - $user_info = [ - 'username' => $username, - 'password' => $password, - ]; - $site_model = new Site(); - $result = $site_model->addSite($shop_data, $user_info, false); - if ($result['code'] == 0) { - $log = array( - "uid" => 0, - "username" => $username, - "site_id" => $data['ag_site_id'], - "url" => '', - "ip" => request()->ip(), - "data" => json_encode($shop_data), - "action_name" => '云市场自动注册店铺', - "create_time" => time(), - ); - model("user_log")->add($log); - $user_info['password']=$_see_password; - $user_info['mobile']=$mobile; - event('AlipayServicemarketAddSite',$user_info); - } - return success('0', '注册成功', $result); - } - - - public function rsaCheck($param) - { - $payModel = new MinCode(); - $res = $payModel->verifySgin($param); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/CloudPay.php b/addon/aliapp/model/CloudPay.php deleted file mode 100644 index 8790c30..0000000 --- a/addon/aliapp/model/CloudPay.php +++ /dev/null @@ -1,609 +0,0 @@ -config_info = $config_info; - // 获取支付宝支付参数(统一支付到平台账户) - $this->aop = new AopClient(); - $this->aop->alipayrsaPublicKey = $config_info['public_key'] ?? ""; - $this->aop->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; - $this->aop->isv_app_id = $config_info["isv_app_id"] ?? ""; - $this->aop->rsaPrivateKey = $config_info['private_key'] ?? ""; - $this->aop->gatewayUrl = 'https://apigw.alipay-eco.com'; - $this->aop->alipaySdkVersion = "alipay-sdk-php-20200415"; - $this->aop->apiVersion = '1.0'; - $this->aop->signType = 'RSA2'; - $this->aop->postCharset = 'UTF-8'; - $this->aop->format = 'json'; - } catch (\Exception $e) { - throw new ApiException(-1, '支付宝配置错误'); - } - } - - /*** - * 支付回调 - * @throws \Exception - */ - public function payNotify() - { - $service = input('service', '-------'); - Log::log('info', '芝麻状态通知:' . $service . ':' . json_encode($_POST)); - if ($this->rsaCheckV(request()->post())) { - $biz_content = json_decode(input('biz_content'), true); - switch ($_POST['service']) { - case 'spi.fitness.subscription.syncSubscription': //订购状态通知 - $res = $this->syncSubscription($biz_content); - break; - case 'spi.fitness.order.syncOrder': - $res = $this->syncOrder($biz_content); - break; - case 'spi.fitness.merchant.syncStatus'://商户状态 - $res = $this->syncStatus($biz_content); - break; - case 'spi.fitness.subscription.getActivateInfo'://周期商品回调 - $res = $this->getActivateInfo($biz_content); - break; - default: - $fail = [ - 'success' => false, - 'code' => 10000, - "msg" => 'Success', - "sub_code" => 'INVALID_PARAMS', - "sub_msg" => '未找到服务方式', - ]; - ksort($fail); - $json = [ - 'response' => $fail, - 'sign' => $this->aop->sign(json_encode($fail), "RSA2") - ]; - echo json_encode($json); - } - } else { - $fail = [ - 'success' => false, - 'code' => 10000, - "msg" => 'Success', - "sub_code" => 'INVALID_PARAMS', - "sub_msg" => '验签失败', - ]; - ksort($fail); - $json = [ - 'response' => $fail, - 'sign' => $this->aop->sign(json_encode($fail), "RSA2") - ]; - echo json_encode($json); - } - } - - - /*** - * 获取验证数据 - * @param $biz_content - * @return void - */ - public function getActivateInfo($biz_content) - { - if (isset($biz_content['productNo'])) { - $outSubscriptionNo = $biz_content['outSubscriptionNo']; - $res = cache($outSubscriptionNo); - cache($outSubscriptionNo, $res); - unset($res['appSubscriptionUrl']); - } else { //分享 - - } - $success = [ - 'code' => "10000", - "msg" => "Success", - ]; - if ($res) { - $success = array_merge($success, $res); - } - ksort($success); - $json = [ - 'response' => $success, - 'sign' => $this->aop->sign(json_encode($success, JSON_UNESCAPED_UNICODE), "RSA2") - ]; - echo json_encode($json); - } - - /*** - * 商户状态 - * @param $data - */ - public function syncStatus($data) - { - if (isset($data['merchantPid']) && $data['merchantPid']) { - $merchant_smid = $data['merchantPid']; - $merchantStatus = $data['merchantStatus']; - $recentZhimaReviewStatus = $data['recentZhimaReviewStatus']; -// $merchantStatus=[ -// 'NORMAL'=>'正常', -// 'ABNORMAL'=>'异常商户', -// 'PAUSING'=>'暂停中', -// 'PAUSED'=>'已暂停', -// 'CLOSING'=>'关闭中', -// 'CLOSED'=>'已关闭', -// 'RECOVERING'=>'恢复中', -// ]; -// $recentZhimaReviewStatus=[ -// 'INCOMPLETE'=>'未补全', -// 'UNDER_REVIEW'=>'审核中', -// 'PASSED'=>'已通过', -// 'FAILED'=>'未通过', -// ]; - $reviewFailReason = $data['reviewFailReason'] ?? ''; - switch ($recentZhimaReviewStatus) { - case 'PASSED': - case 'NORMAL': - $is_zmpay = 1; - break; - case 'UNDER_REVIEW': - $is_zmpay = 0; - break; - case 'FAILED': - $is_zmpay = 2; - break; - } - Db::name('pay_shop')->where('merchant_smid', '=', $merchant_smid)->update([ - 'is_zmpay' => $is_zmpay, - 'merchantStatus' => $merchantStatus, - 'ZhimaReviewStatus' => $recentZhimaReviewStatus, - 'zmapply_desc' => $reviewFailReason, - ]); - } - $success = [ - 'success' => true, - 'code' => 10000, - "msg" => 'Success', - ]; - ksort($success); - $json = [ - 'response' => $success, - 'sign' => $this->aop->sign(json_encode($success), "RSA2") - ]; - echo json_encode($json); - } - - /*** - * 订单回调 - * @param $data - * @throws \Exception - */ - public function syncSubscription($data) - { - $out_trade_no = $data['outSubscriptionNo']; - // 支付宝交易号 - $trade_no = $data['subscriptionNo']; - // 交易状态 - $trade_status = $data['subscriptionStatus']; - switch ($trade_status) { - case 'NORMAL': //正常 - $pay_common = new PayCommon(); - $retval = $pay_common->onlinePay($out_trade_no, "zmxxpay", $trade_no, "cardservice"); - if (empty($retval['data'])) { - $fail = [ - 'code' => '40000', - "msg" => 'Failed', - "sub_code" => 'INVALID_PARAMS', - "sub_msg" => '参数异常', - ]; - ksort($fail); - $json = [ - 'response' => $fail, - 'sign' => $this->aop->sign(json_encode($fail, JSON_UNESCAPED_UNICODE), "RSA2") - ]; - echo json_encode($json); - return; - } - break; - case 'PAUSED': //订单暂停 - $where = [ - 'trade_no' => $trade_no - ]; - Db::name('member_goods_card')->where($where)->update(['status' => 2, 'jsonValue' => json_encode($data)]); - break; - case "CANCEL": //超时取消 - case "END": //订单结束 - case "DEFAULT_CANCEL": //违约取消 - $where = [ - 'trade_no' => $trade_no - ]; - Db::name('member_goods_card')->where($where)->update(['status' => 0, 'jsonValue' => json_encode($data)]); - break; - case "SURRENDER": //解约 - $where = [ - 'trade_no' => $trade_no - ]; - Db::name('member_goods_card')->where($where)->update(['status' => 4, 'jsonValue' => json_encode($data)]); - break; - default: - $fail = [ - 'success' => false, - 'code' => 10000, - "msg" => 'Success', - "sub_code" => 'INVALID_PARAMS', - "sub_msg" => '未找到业务类型', - ]; - ksort($fail); - $json = [ - 'response' => $fail, - 'sign' => $this->aop->generateSign($fail, "RSA2") - ]; - echo json_encode($json); - return; - } - $success = [ - 'success' => true, - 'code' => 10000, - "msg" => 'Success', - ]; - ksort($success); - $json = [ - 'response' => $success, - 'sign' => $this->aop->sign(json_encode($success), "RSA2") - ]; - echo json_encode($json); - } - - - /*** - * 订单同步状态 - * @param $data - */ - public function syncOrder($data) - { - $out_trade_no = $data['outSubscriptionNo']; //平台交易号 - // 支付宝交易号 - $trade_no = $data['subscriptionNo']; - $third_order_no = $data['orderNo']; - // 交易状态 - $trade_status = $data['orderStatus']; - $where = [ - 'out_trade_no' => $out_trade_no, - 'third_order_no' => $third_order_no - ]; - $orderInfo = (array)model('order')->getInfo([['out_trade_no', '=', $out_trade_no]], 'site_id,store_id,order_id,member_id,name,mobile,province_id,city_id,district_id,address,full_address,promotion_type,promotion_type_name'); - $zmOrder = Db::name('zima_order')->where($where)->find(); - if (empty($zmOrder)) { - $insdata = [ - 'productNo' => $data['productNo'], - 'merchantPid' => $data['merchantPid'], - 'site_id' => $orderInfo['site_id'], - 'store_id' => $orderInfo['store_id'], - 'userid' => $data['userId'], - 'order_id' => $orderInfo['order_id'] ?? 0, - 'uid' => $orderInfo['member_id'] ?? 0, - 'trade_no' => $trade_no, - 'out_trade_no' => $out_trade_no, - 'third_order_no' => $third_order_no, - 'verificationCodeStatus' => $data['verificationCodeStatus'] ?? '', - 'orderSettleStatus' => $data['orderSettleStatus'], - 'create_time' => strtotime($data['orderDate']), - 'plan_time' => strtotime($data['planDeductionTime'] ?? ''), - 'period' => $data['period'], - 'order_status' => $trade_status, - 'amount' => $data['deductionAmount'] - ]; - Db::name('zima_order')->insert($insdata); - } else { - $updata = [ - 'order_status' => $trade_status, - 'verificationCodeStatus' => $data['verificationCodeStatus'] ?? '', - 'orderSettleStatus' => $data['orderSettleStatus'], - 'settleTime' => $data['settleTime'] ?? 0, - 'failTimes' => $data['failTimes'] ?? 0, - 'failReason' => $data['failReason'] ?? '', - ]; - if ($trade_status == 'PAID') { //扣款成功 - $updata['payChannel'] = $data['payChannel']; - $updata['settleDetails'] = json_encode($data['settleDetails']); - $updata['pay_time'] = strtotime($data['actualDeductionTime']); - event('CloudAliPayOrderPay', array_merge($zmOrder, $updata, $orderInfo));//订单支付成功 - } - Db::name('zima_order')->where($where)->update($updata); - //核销支付中 - try { - event('CloudAliPaySyncOrder', array_merge($zmOrder, $updata, $orderInfo));//订单同步事件 - } catch (\Exception $exception) { - trace($exception, 'CloudAliPaySyncOrder同步事件' . json_encode($data)); - } - } - $success = [ - 'success' => true, - 'code' => 10000, - "msg" => 'Success', - ]; - ksort($success); - $json = [ - 'response' => $success, - 'sign' => $this->aop->sign(json_encode($success), "RSA2") - ]; - echo json_encode($json); - } - - /*** - * 退款 - */ - public function refund($param) - { - $pay_info = $param['pay_info']; - $bizContent = [ - 'merchantPid' => $pay_info['merchantPid'], - 'subscriptionNo' => $pay_info['trade_no'], - 'orderNo' => $pay_info['order_no'] - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.orderRefund"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result; - } - - /*** - * 新增或者修改商户 - * @param $param - * @return false|mixed - */ - public function upAlipayUser($param, $settleAccountList = '', $site_id = 0) - { - $bizContent = [ - 'merchantPid' => $param['smid'], - 'smid' => $param['smid'], - 'merchantAppId' => $param['merchantAppId'], - 'merchantLoginName' => $param['merchantLoginName'], - 'merchantName' => $param['merchantName'], - 'separateLedgerRate' => $param['separateLedgerRate'], - 'phone' => $param['phone'], - 'logoUrl' => $param['logoUrl'] ?? '' - ]; - if ($settleAccountList) { - $bizContent['settleAccountList'] = array_values($settleAccountList); - } - $proxy_url = config('alipay.cloudAlipay.proxy_url'); - if ($proxy_url) { - $this->http_post_data($proxy_url, ['userId' => $param['smid'], 'domain' => addon_url('pay/pay/cloudnotify'), 'site_id' => $site_id]); - } - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.newSaveOrUpdate"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result['response']; - } - - - public function merchantApplyInfoQuery($merchantPid,$site_id) - { - $bizContent = [ - 'merchantPid' => $merchantPid - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.merchantApplyInfoQuery"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result['response']; - } - /*** - * 上传图片 - * @param $base64Img - * @return mixed - */ - public function logoUpload($base64Img) - { - $bizContent = [ - 'picData' => $base64Img - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.logoUpload"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - // 调用ECOAPI - $httpClient = new HttpClient(); - $res = $httpClient->post($this->aop->gatewayUrl, $params); - // 将返回结果转换本地文件编码 - $result = json_decode($res, true); - return $result['response']; - } - - /*** - * 商户解约 - * @param $param - * @return false|mixed - */ - public function Surrender($subscriptionNo, $type = 'NORMAL') - { - $bizContent = [ - 'subscriptionNo' => $subscriptionNo, - 'subscriptionCancelType' => $type //NORMAL 正常 DEFAULT违约 - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.subscriptionSurrender"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result; - } - - /*** - * 核销 - * @param $verificationCode - * @param $orderNo - * @return false|mixed - */ - public function verify($verificationCode, $orderNo = '') - { - $bizContent = [ - 'verificationCode' => $verificationCode - // 'orderNo'=>$orderNo, - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.verification"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result; - } - - /*** - * 订单查询 - * @param $subscriptionNo - * @param $orderNo - * @return false|mixed - */ - public function orderQuery($subscriptionNo = '', $orderNo = '', $verificationCode = '') - { - $bizContent = [ - 'subscriptionNo' => $subscriptionNo, - 'orderNo' => $orderNo, - 'verificationCode' => $verificationCode, - ]; - //其他参数 - $params["charset"] = "UTF-8"; - $params["isv_app_id"] = $this->aop->isv_app_id; - $params["utc_timestamp"] = $this->msectime(); - //指定需要调用的service接口 - $params["service"] = "api.fitness.orderQuery"; - $params["request_id"] = $this->uuid(); - $params["biz_content"] = json_encode($bizContent); - $params["version"] = "1.0"; - $params["sign"] = $this->aop->generateSign($params, "RSA2"); - $params["sign_type"] = 'RSA2'; - // 调用ECOAPI - $result = $this->aop->call($params); - return $result; - } - - public function imageUpload($site_id, $image_url, $image_name = '图片', $isCache = false) - { - $ali = new MinCode($site_id); - $result = $ali->imageUpload($image_name, $image_url, $isCache); - $result = $result['alipay_offline_material_image_upload_response']; - if ($result['code'] == 10000) { - return success(0, '', $result); - } else { - return error(-1, $result['sub_msg']); - } - } - - /*** - * 验证签名 - * @param $data - * @return bool|void - */ - public function rsaCheckV($data) - { - unset($data['sign_type']); - $res = $this->aop->rsaCheckV2($data, $this->aop->alipayrsaPublicKey, 'RSA2'); - return $res; - } - - /** - * 返回当前的毫秒时间戳 - */ - public function msectime() - { - list($s1, $s2) = explode(' ', microtime()); - return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); - } - - public function http_post_data($url, $params = array()) - { - if (is_array($params)) { - $params = http_build_query($params, null, '&'); - } - $ch = curl_init(); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - $response = curl_exec($ch); - curl_close($ch); - return $response; - } - - /** - * 生成UUID - */ - public function uuid() - { - $chars = md5(uniqid(mt_rand(), true)); - $uuid = substr($chars, 0, 8) . '-' - . substr($chars, 8, 4) . '-' - . substr($chars, 12, 4) . '-' - . substr($chars, 16, 4) . '-' - . substr($chars, 20, 12); - return $uuid; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/Config.php b/addon/aliapp/model/Config.php deleted file mode 100644 index 49e3f69..0000000 --- a/addon/aliapp/model/Config.php +++ /dev/null @@ -1,65 +0,0 @@ -$site_id, - 'appid'=>$appid - ]; - $res = $config->setUniConfig($condition,$data,'aliapp','ALIAPP_CONFIG',$app_original); - return $res; - } - - /** - * 获取小程序配置信息 - * @return multitype:string mixed - */ - public function getAppConfig($site_id,$app_type='aliapp', $config_key = 'ALIAPP_CONFIG') - { - $config = new UniAccount(); - $condition=[ - 'site_id'=>$site_id, - 'app_type'=>$app_type - ]; - $res = $config->getUniConfig($condition,$config_key); - return $res; - } - /** - * 根据appid获取配置信息 - * @return multitype:string mixed - */ - public function getAppidConfig($appid,$config_key = 'ALIAPP_CONFIG') - { - $config = new UniAccount(); - $res = $config->getUniConfig(['appid', '=', $appid],$config_key); - return $res; - } - - public function getOpenConfig(){ - $config = new ConfigModel(); - $res = $config->getConfig([['site_id', '=', 0], ['app_module', '=', 'admin'], ['config_key', '=', 'ALIPAYOPEN_CONFIG']]); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/model/CreateApplet.php b/addon/aliapp/model/CreateApplet.php deleted file mode 100644 index aa30754..0000000 --- a/addon/aliapp/model/CreateApplet.php +++ /dev/null @@ -1,167 +0,0 @@ -site_id = $siteId; - // 获取参数信息 - $params = $this->createAppletParams($info); - $result = (new MinCode())->requestApi("alipay.open.mini.isv.create", ['create_mini_request' => $params])['alipay_open_mini_isv_create_response']; - - if ($result['code'] == 10000) { - $info['out_order_no'] = $params['out_order_no']; - $info['order_no'] = $result['order_no']; - - return $this->success($info); - } else { - throw new Exception($result['sub_msg']); - } - } - - /** - * Common: 创建小程序 —— 参数获取 - * Author: wu-hui - * Time: 2022/12/29 9:10 - * @param $info - * @return array - */ - private function createAppletParams($info) - { - // 获取图片base64 - if ($info['license_pic']) $info['license_pic'] = UrlimgBase64(img($info['license_pic'])); - // 处理配置信息 - $info['out_order_no'] = $this->createAppletOutOrderNo($this->site_id, $info['cert_no']); - - return [ - 'out_order_no' => $info['out_order_no'], // 开发者外部订单号 - 'alipay_account' => $info['alipay_account'], // 商家登录支付宝的邮箱帐号或手机号 - 'legal_personal_name' => $info['legal_personal_name'],// 商家法人名称 - 'cert_name' => $info['cert_name'],// 营业执照企业名称,如果是“无主体名称个体工商户”则填“个体户+法人姓名”,例如“个体户张三” - 'cert_no' => $info['cert_no'],// 营业执照编码 - 'app_name' => $info['app_name'], // 小程序名称 - 'contact_phone' => $info['contact_phone'], // 商家联系人手机电话 - 'contact_name' => $info['contact_name'], // 商家联系人名称 - 'is_individual' => TRUE, // 是否支持个体工商户的账号类型 - 'license_pic' => $info['license_pic'], // 营业执照图片的Base64编码字符串,图片大小不能超过2M。 - ]; - } - - /** - * Common: 生成订单号 - * Author: wu-hui - * Time: 2022/12/28 16:54 - * @param $site_id - * @param $id - * @return string - */ - public function createAppletOutOrderNo($site_id, $cert_no) - { - $time_str = date('YmdHi'); - $max_no = Cache::get($site_id . '_' . $cert_no . '_' . $time_str); - if (!isset($max_no) || empty($max_no)) $max_no = 1; - else $max_no = $max_no + 1; - $order_no = $time_str . $cert_no . sprintf('%03d', $max_no); - Cache::set($site_id . '_' . $cert_no . '_' . $time_str, $max_no); - return $order_no; - } - - - /** - * Common: 获取最新的小程序配置信息 - * Author: wu-hui - * Time: 2022/12/28 17:41 - * @param $siteId - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function getNewParams($siteId) - { - $info = Db::name('applet_list') - ->where('site_id', $siteId) - ->where('type', 1) - ->order('id', 'DESC') - ->find(); - if (!$info) { - $content = [ - 'alipay_account' => '',// 商家登录支付宝的邮箱帐号或手机号 - 'legal_personal_name' => '',// 商家法人名称 - 'cert_name' => '',// 营业执照企业名称,如果是“无主体名称个体工商户”则填“个体户+法人姓名”,例如“个体户张三” - 'cert_no' => '',// 营业执照编码 - 'app_name' => '',// 小程序名称 - 'contact_phone' => '',// 商家联系人手机电话 - 'contact_name' => '',// 商家联系人名称 - 'license_pic' => '',// 营业执照图片的Base64编码字符串,图片大小不能超过2M。 - ]; - } else { - $content = json_decode($info['content'], TRUE); - } - - return [$info['id'] ?? 0, $content]; - } - - /** - * Common: 设置小程序信息 - * Author: wu-hui - * Time: 2022/12/28 18:15 - * @param $info - * @param $siteId - * @return array - */ - public function setNewParams($info, $siteId) - { - // 信息处理 - $id = $info['id']; - unset($info['id']); - Db::name('applet_list')->startTrans(); - try { - // 发起请求 创建小程序 - $info = $this->createAppletStart($info, $siteId); - $data = [ - 'content' => json_encode($info, JSON_UNESCAPED_UNICODE) - ]; - // 记录信息 - if ($id > 0) { - Db::name('applet_list')->where('id', $id)->update($data); - } else { - $data['site_id'] = $siteId; - $data['name'] = $info['app_name']; - $data['type'] = 1; - $data['status'] = 1; - $data['create_time'] = time(); - Db::name('applet_list')->insert($data); - } - Db::name('applet_list')->commit(); - return $this->success(); - } catch (\Exception $e) { - Db::name('applet_list')->rollback(); - return $this->error('', $e->getMessage()); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/model/Message.php b/addon/aliapp/model/Message.php deleted file mode 100644 index 9252a82..0000000 --- a/addon/aliapp/model/Message.php +++ /dev/null @@ -1,16 +0,0 @@ -getColumn([['aliapp_is_open', '=', 1], ['aliapp_template_id', '<>', ''], ['site_id', '=', $site_id], ['keywords', 'in', explode(',', $keywords)]], 'aliapp_template_id'); - return $this->success($data); - } -} \ No newline at end of file diff --git a/addon/aliapp/model/MinCode.php b/addon/aliapp/model/MinCode.php deleted file mode 100644 index 8e5e0fb..0000000 --- a/addon/aliapp/model/MinCode.php +++ /dev/null @@ -1,457 +0,0 @@ -site_id = $site_id; - $this->platform = config('alipay.platform'); - if ($site_id) { - $config_info = $config_model->getAppConfig($site_id)['data']['value']; - $this->uconfig = $config_info; - if (isset($config_info['line_type']) && $config_info['line_type'] == 'auth') { - $this->appAuthToken = $this->uconfig['app_auth_token']; - $config_info = $this->platform; - } - } else { - $config_info = config('alipay.platform'); - } - $this->config = $config_info; - $options = new AliSdkCon(); - $options->protocol = 'https'; - $options->gatewayHost = 'openapi.alipay.com'; - $options->signType = 'RSA2'; - $options->appId = $config_info['appid'] ?? ''; - // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 - $options->merchantPrivateKey = $config_info['private_key'] ?? ""; //'<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->'; - $options->alipayCertPath = ''; //'<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->'; - $options->alipayRootCertPath = ''; //'<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt" -->'; - $options->merchantCertPath = ''; //'<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->'; - //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 - $options->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; // '<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->'; - //可设置异步通知接收服务地址(可选) - $options->notifyUrl = ''; //"<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->"; - //可设置AES密钥,调用AES加解密相关接口时需要(可选) - $options->encryptKey = $config_info['encryptKey'] ?? ''; // 'du/cSQ7P4YPw4d8+3jUc3w=='; //"<-- 请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA== -->"; - Factory::setOptions($options); - } - - - /*** - * 获取系统配置 - * @return mixed - */ - public function getConfig() - { - $config = $this->uconfig; - $config['platform'] = $this->platform; - return $config; - } - - /** - * 消息解密 - * @param array $param - */ - public function decryptData($encryptedData) - { - try { - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->AES() - ->agent($this->appAuthToken) - ->decrypt($encryptedData); - return json_decode($result, true); - } catch (\Exception $e) { - return $this->error([], $e->getMessage()); - } - } - - /*** - * @param $authCode - * @return array|object|\Psr\Http\Message\ResponseInterface|\WannanBigPig\Supports\Collection|\WannanBigPig\Supports\Http\Response - * @throws \EasyAlipay\Kernel\Exceptions\InvalidSignException - * @throws \GuzzleHttp\Exception\GuzzleException - * @throws \WannanBigPig\Supports\Exceptions\InvalidArgumentException - */ - public function handleAuthorize($authCode, $grant_type = 'authorization_code') - { - try { - $textParams = []; - $bizParams = [ - 'grant_type' => $grant_type, - 'code' => $authCode, - ]; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic()->execute("alipay.open.auth.token.app", $textParams, $bizParams); - return json_decode($result->httpBody, true)['alipay_open_auth_token_app_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /** - * 获取授权地址 - * @param $urls //回调地址 - * @param string $type - * @return string - */ - public function getPreAuthorizationUrl($urls, $type = 'WEBAPP,MOBILEAPP,PUBLICAPP,TINYAPP') - { - $urls = urlencode($urls); - $appid = $this->config['appid'] ?? ''; - $auth_url = "https://openauth.alipay.com/oauth2/appToAppAuth.htm?app_id={$appid}&redirect_uri={$urls}"; - return $auth_url; - } - - - public function getminiAuthorizationUrl($urls, $state) - { - $bizDataObj = [ - 'platformCode' => 'O', - 'taskType' => 'INTERFACE_AUTH', - 'agentOpParam' => [ - 'redirectUri' => $urls, - 'appTypes' => ["TINYAPP", "BASEAPP"], - 'isvAppId' => $this->config['appid'], - 'state' => $state, - ], - ]; - - $bizData = json_encode($bizDataObj); - $url = urlencode('pages/authorize/index?bizData=' . $bizData); - $auth_url = "alipays://platformapi/startapp?appId=2021003130652097&page={$url}"; - return $auth_url; - } - - - /** - * Common: 支付宝用户相关请求 - * Author: wu-hui - * Time: 2023/01/05 13:44 - * @param $authToken - * @param $api - * @param array $params - * @param array $textParams - * @return mixed|string - */ - public function requestMemberApi($authToken, $api, $params = [], $textParams = []) - { - try { - $result = Factory::util() - ->generic() - ->agent($this->appAuthToken) - ->auth($authToken) - ->execute($api, $textParams, $params); - return json_decode($result->httpBody, true); - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /** - * Common: 发起支付宝请求 - * Author: wu-hui - * Time: 2022/12/28 17:31 - * @param $api - * @param array $params - * @param array $textParams - * @return mixed|string - */ - public function requestApi($api, $params = [], $textParams = []) - { - try { - $result = Factory::util() - ->generic() - ->agent($this->appAuthToken) - ->execute($api, $textParams, $params); - return json_decode($result->httpBody, true); - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - /*** - * 验签 - * @param $param - * @return bool - */ - public function verifySgin($param) - { - $res = Factory::payment()->common()->verifyNotify($param); - return $res; - } - - /*** - * 签名 - * @param $param - * @return bool - */ - public function encrypt($param) - { - $res = Factory::Util()->AES()->encrypt($param); - return $res; - } - - - /*** - * 查询小程序信息 - * @param $order_no - * @param $appAuthToken - * @return mixed|string - */ - public function miniQuery($order_no, $appAuthToken) - { - try { - $biz_content['order_no'] = $order_no; - $result = Factory::util()->generic() - ->agent($appAuthToken) - ->execute('alipay.open.mini.isv.query', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_mini_isv_query_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - /*** - * 查询订购订单 - * @param $commodity_order_id - * @param int $start_page - * @return mixed|string - */ - public function queryServiceOrder($commodity_order_id, $start_page = 1) - { - try { - $biz_content['commodity_order_id'] = $commodity_order_id; - $biz_content['start_page'] = $start_page; - $result = Factory::util()->generic() - ->execute('alipay.open.servicemarket.order.query', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_servicemarket_order_query_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 查询订购订单 - * @param $commodity_order_id - * @param int $start_page - * @return mixed|string - */ - public function MiniCreate($biz_content) - { - try { - $result = Factory::util() - ->generic() - ->execute('alipay.open.mini.isv.create', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_mini_isv_create_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 设置小程序基础信息 - * @param $textParams - * @return mixed|string - */ - public function miniSetBaseinfo($textParams, $app_logo) - { - $fileParams = [ - 'app_logo' => $app_logo, - ]; - try { - $result = Factory::util() - ->generic() - ->agent($this->appAuthToken) - ->fileExecute("alipay.open.mini.baseinfo.modify", $textParams, [], $fileParams); - return json_decode($result->httpBody, true)['alipay_open_mini_baseinfo_modify_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /** - * 订单发货 - * @param $param - * @return array - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function sendDelivery($biz_content) - { - try { - $result = Factory::util()->generic() - ->agent($this->appAuthToken) - ->execute('alipay.open.mini.order.delivery.send', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_mini_order_delivery_send_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /** - * 订单收货 - * @param $param - * @return array - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function recieveDelivery($biz_content) - { - try { - $result = Factory::util()->generic() - ->agent($this->appAuthToken) - ->execute('alipay.open.mini.order.delivery.receive', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_mini_order_delivery_receive_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - /*** - * 查询订单信息 - * @param $order_no - * @param $openid - * @return mixed|string - */ - public function miniOrderQuery($order_no, $openid) - { - try { - $biz_content['out_order_id'] = $order_no; - $biz_content['user_id'] = $openid; - $result = Factory::util()->generic() - ->agent($this->appAuthToken) - ->execute('alipay.open.mini.order.query', [], $biz_content); - return json_decode($result->httpBody, true)['alipay_open_mini_order_query_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - /*** - * 下单前安全检查 - * @return void - */ - public function PaySecurityCheck() - { - $config = new Config(); - $app_info = $config->getAppConfig($this->site_id)['data']['value']; - $info = cache($this->appAuthToken . '_baseinfo'); - //验证客服电话 - if (empty($info) || !isset($app_info['service_phone'])) { - $baseinfo = $this->requestApi('alipay.open.mini.baseinfo.query')['alipay_open_mini_baseinfo_query_response']; - cache($this->appAuthToken . '_baseinfo', $baseinfo, 600); - if ($baseinfo['code'] == 10000 && $baseinfo['service_phone']) { - if (in_array($baseinfo['service_phone'], ['13800000001', '13800138000']) || $baseinfo['service_phone'] == '') { - return $this->error('', '商家客服热线异常'); - } else { - $app_info['service_phone'] = $baseinfo['service_phone']; - $app_original = $app_info['app_original']; - $config->setAlipayConfig($app_info['appid'], $app_info, $this->site_id, $app_original); - } - } - } else { - if (in_array($app_info['service_phone'], [13800000001, 13800138000])) { - return $this->error('', '商家客服热线异常'); - } - } - //检查商家是否有维权 - $trade_complain_infos = cache($this->appAuthToken . 'trade_complain_infos'); - if ($trade_complain_infos) return $this->error('', '维权投诉待处理'); - - //判断商家是否无维权 - $no_trade_complain_infos = cache($this->appAuthToken . 'no_trade_complain_infos'); - if ($no_trade_complain_infos) return $this->success('无异常'); - //验证售后 - $condition = [ - 'page_num' => 1, - 'page_size' => 10, - 'status' => 'MERCHANT_PROCESSING', - ]; - $request = $this->requestApi('alipay.merchant.tradecomplain.batchquery', $condition); - $res = $request['alipay_merchant_tradecomplain_batchquery_response']; - if ($res['code'] == 10000 && isset($res['trade_complain_infos'])) { - cache($this->appAuthToken . 'trade_complain_infos', count($res['trade_complain_infos']), 300); - cache($this->appAuthToken . 'no_trade_complain_infos', null); - return $this->error('', '维权投诉待处理'); - } else { - cache($this->appAuthToken . 'trade_complain_infos', null); - cache($this->appAuthToken . 'no_trade_complain_infos', 1, 7200); - } - return $this->success('无异常'); - } - - - public function getCompanyList() - { - $json = file_get_contents(__DIR__ . '/alikd.json'); - return json_decode($json, true); - } - - /** - * Common: 发起支付宝请求 - * @param $api - * @param array $params - * @param array $textParams - * @return mixed|string - */ - public function imageUpload($imageName, $imageFilePath, $isCache = false) - { - try { - if ($isCache && cache(md5($imageName))) { - $data = json_decode(cache(md5($imageName)), true); - return $data; - } - $result = Factory::base() - ->image() - ->agent($this->appAuthToken) - ->upload($imageName, $imageFilePath); - if ($isCache) { - $data = json_decode($result->httpBody, true); - cache(md5($imageName), json_encode($data)); - return $data; - } - return json_decode($result->httpBody, true); - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - public function getUserPhoneNumber($param) - { - try { - if (!isset($param['sign'])) return $this->error([], '商户未获得手机号接口权限'); - $encryptedData = $param['sign']; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->AES() - ->agent($this->appAuthToken) - ->decrypt($encryptedData); - return json_decode($result, true); - } catch (\Exception $e) { - return $this->error([], $e->getMessage()); - } - } -} diff --git a/addon/aliapp/model/OpenPay.php b/addon/aliapp/model/OpenPay.php deleted file mode 100644 index 14b2de4..0000000 --- a/addon/aliapp/model/OpenPay.php +++ /dev/null @@ -1,248 +0,0 @@ -config = $config_info; - $options = new AliCon(); - $options->protocol = 'https'; - $options->gatewayHost = 'openapi.alipay.com'; - $options->signType = 'RSA2'; - $options->appId = $config_info['appid']; - // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 - $options->merchantPrivateKey = $config_info['private_key'] ?? ""; //'<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->'; - //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 - $options->alipayPublicKey = $config_info['alipay_public_key'] ?? ""; // '<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->'; - //可设置异步通知接收服务地址(可选) - $options->notifyUrl = ''; //"<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->"; - //可设置AES密钥,调用AES加解密相关接口时需要(可选) - $options->encryptKey = $config_info['encryptKey']; //"<-- 请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA== -->"; - $options->alipayCertPath = ''; //'<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->'; - $options->alipayRootCertPath = ''; //'<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt" -->'; - $options->merchantCertPath = ''; //'<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->'; - Factory::setOptions($options); - } - - - /*** - * 直通商户进件 - * @param $bizParams - * @return mixed|string - */ - public function simpleCreate($bizParams) - { - try { - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.simplecreate", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_simplecreate_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - public function modifycreate($bizParams) - { - try { - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.modify", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_modify_response']; - } catch (\Exception $e) { - } - } - - /*** - * 修改直付通信息 - * @param $bizParams - * @return mixed|string - */ - public function modify($bizParams) - { - try { - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.modify", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_modify_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 修改结算信息 - * @param $bizParams - * @return mixed|string - */ - public function settlementmodify($bizParams) - { - try { - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.settlementmodify", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_settlementmodify_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 直付通商户创建预校验咨询 - * @param $bizParams - * @return mixed|string - */ - public function antMerchantExpandIndirectZftConsult($bizParams) - { - try { - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.consult", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_consult_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 删除商户 - * @param $bizParams - * @return mixed|string - */ - public function MerchantDelete($smid) - { - try { - $bizParams=[ - 'smid'=>$smid - ]; - $textParams = []; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zft.delete", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zft_delete_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - - /*** - * 查询状态 - * @param string $external_id - * @param string $order_id - * @return mixed|string - */ - public function query($external_id = '', $order_id = '') - { - try { - $textParams = []; - if($external_id && $order_id){ - $bizParams = [ - 'external_id' => $external_id, - 'order_id' => $order_id - ]; - }else if ($external_id) { - $bizParams = [ - 'external_id' => $external_id, - ]; - } else if ($order_id) { - $bizParams = [ - 'order_id' => $order_id - ]; - } - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->execute("ant.merchant.expand.indirect.zftorder.query", $textParams, $bizParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_zftorder_query_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 上传图片 - * @param string $image_type - * @param $image_content - * @return mixed|string - */ - public function upload($image_type = '', $image_content) - { - try { - $textParams = [ - 'image_type' => $image_type, - ]; - $fileParams = [ - 'image_content' => $image_content, - ]; - //2. 发起API调用(以支付能力下的统一收单交易创建接口为例) - $result = Factory::util() - ->generic() - ->fileExecute("ant.merchant.expand.indirect.image.upload", $textParams, [], $fileParams); - return json_decode($result->httpBody, true)['ant_merchant_expand_indirect_image_upload_response']; - } catch (\Exception $e) { - return $e->getMessage(); - } - } - - /*** - * 验签 - * @param $param - * @return bool - */ - public function verifySgin($param) - { - $res = Factory::payment() - ->common() - ->verifyNotify($param); - return $res; - } - - /** - * Common: 发起支付宝请求 - * Author: wu-hui - * Time: 2023/01/31 16:06 - * @param $api - * @param array $params - * @param array $textParams - * @return mixed|string - */ - public function requestApi($api, $params = [], $textParams = []){ - try { - $result = Factory::util()->generic()->execute($api,$textParams,$params); - return json_decode($result->httpBody, true); - } catch (\Exception $e) { - return $e->getMessage(); - } - } -} diff --git a/addon/aliapp/model/TradeComplain.php b/addon/aliapp/model/TradeComplain.php deleted file mode 100644 index df92520..0000000 --- a/addon/aliapp/model/TradeComplain.php +++ /dev/null @@ -1,36 +0,0 @@ -requestApi('alipay.merchant.tradecomplain.batchquery', $condition); - $res = $request['alipay_merchant_tradecomplain_batchquery_response']; - if ($res['code'] == 10000) { - if (isset($res['trade_complain_infos'])) { - $arr = array_column($res['trade_complain_infos'], 'merchant_order_no'); - $orderList = model('order')->getColumn([['out_trade_no', 'in', $arr]], 'order_id,refund_status,is_lock,out_trade_no', 'out_trade_no'); - $ordergoods_ids = model('order_goods')->getColumn([['order_id', 'in', array_column($orderList,'order_id')]], 'order_goods_id', 'order_id'); - foreach ($res['trade_complain_infos'] as $key => &$item) { - if (isset($orderList[$item['merchant_order_no']])) { - $item['is_sync_bill'] = 1; - $orderid=$orderList[$item['merchant_order_no']]['order_id']; - $item['order_goods_id'] = $orderid; - } else { - $item['is_sync_bill'] = 0; - } - } - } - } - return $this->success($res); - } -} \ No newline at end of file diff --git a/addon/aliapp/model/UploadFile.php b/addon/aliapp/model/UploadFile.php deleted file mode 100644 index 0b72a8c..0000000 --- a/addon/aliapp/model/UploadFile.php +++ /dev/null @@ -1,35 +0,0 @@ -imageUpload(md5($key), $file_path, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - $data = array( - "type" => 'alipay', - "path" => $res['image_url'], - "url" => $res['image_url'], - "domain" => '', - "image_id" => $res['image_id'], - "bucket" => $res['image_id'] - ); - return $this->success($data); - } else { - return $this->error($res); - } - } catch (\Exception $e) { - return $this->error( $e->getMessage()); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/model/alikd.json b/addon/aliapp/model/alikd.json deleted file mode 100644 index db02134..0000000 --- a/addon/aliapp/model/alikd.json +++ /dev/null @@ -1 +0,0 @@ -[{"delivery_id":"DYZT","delivery_name":"\u9012\u6613\u81ea\u63d0\u67dc"},{"delivery_id":"SHQ","delivery_name":"\u534e\u5f3a\u7269\u6d41"},{"delivery_id":"HZABC","delivery_name":"\u7231\u5f7c\u897f"},{"delivery_id":"POSTB","delivery_name":"\u90ae\u653f\u56fd\u5185\u5c0f\u5305"},{"delivery_id":"DYKD","delivery_name":"\u5927\u6d0b\u5feb\u9012\uff08\u5929\u6d25\uff09"},{"delivery_id":"GWTP","delivery_name":"\u5fae\u7279\u6d3e\uff08\u5e7f\u5dde\uff09"},{"delivery_id":"SURE","delivery_name":"\u901f\u5c14"},{"delivery_id":"AIR","delivery_name":"\u4e9a\u98ce"},{"delivery_id":"DY","delivery_name":"\u57ce\u5e02\u4e00\u767e"},{"delivery_id":"GHWL","delivery_name":"\u6842\u534e\u7269\u6d41"},{"delivery_id":"CYEXP","delivery_name":"\u957f\u5b87"},{"delivery_id":"FCBOX","delivery_name":"\u4e30\u5de2\u667a\u80fd\u67dc"},{"delivery_id":"BESTQJT","delivery_name":"\u767e\u4e16\u7269\u6d41"},{"delivery_id":"ZJEZ","delivery_name":"e\u6808"},{"delivery_id":"ZTKY","delivery_name":"\u4e2d\u94c1\u7269\u6d41"},{"delivery_id":"NEDA","delivery_name":"\u6e2f\u4e2d\u80fd\u8fbe"},{"delivery_id":"QLWL","delivery_name":"\u9752\u65c5\u7269\u6d41"},{"delivery_id":"ZOREL","delivery_name":"\u4e2d\u777f\u901f\u9012"},{"delivery_id":"ASTGJ","delivery_name":"\u5b89\u4e16\u901a\u56fd\u9645\u5feb\u9012"},{"delivery_id":"MDMSM","delivery_name":"\u95e8\u5bf9\u95e8"},{"delivery_id":"FYWL","delivery_name":"\u98de\u9e70\u8d27\u8fd0"},{"delivery_id":"HYKD","delivery_name":"\u9e3f\u6021\u5feb\u9012"},{"delivery_id":"ZHKDGS","delivery_name":"\u7eb5\u6a2a\u5feb\u9012"},{"delivery_id":"JXFY","delivery_name":"\u98de\u8fdc\uff08\u6c5f\u897f\uff09"},{"delivery_id":"XFDWL","delivery_name":"\u5148\u98de\u8fbe\u7269\u6d41"},{"delivery_id":"UC","delivery_name":"\u4f18\u901f\u5feb\u9012"},{"delivery_id":"ZJS","delivery_name":"\u5b85\u6025\u9001"},{"delivery_id":"SCWLZP","delivery_name":"\u901f\u5448\u5b85\u914d"},{"delivery_id":"RFDSM","delivery_name":"\u5982\u98ce\u8fbe"},{"delivery_id":"ATWL","delivery_name":"\u5b89\u7530\u7269\u6d41"},{"delivery_id":"ZTO","delivery_name":"\u4e2d\u901a\u901f\u9012"},{"delivery_id":"ZLWM","delivery_name":"\u4e2d\u7cae\u6211\u4e70\u7f51"},{"delivery_id":"COSCOAIR2012","delivery_name":"\u4e2d\u8fdc\u7a7a\u8fd0"},{"delivery_id":"ZMKM","delivery_name":"\u4e39\u9e1f"},{"delivery_id":"FEDEX","delivery_name":"\u8054\u90a6\u5feb\u9012"},{"delivery_id":"NX","delivery_name":"\u9e1f\u7bb1"},{"delivery_id":"NXWJT","delivery_name":"\u5b81\u590f\u4e07\u5bb6\u901a"},{"delivery_id":"HTKY","delivery_name":"\u767e\u4e16\u5feb\u9012"},{"delivery_id":"SJTC","delivery_name":"\u4e16\u7eaa\u540c\u8bda"},{"delivery_id":"XLOBO","delivery_name":"\u8d1d\u6d77\u56fd\u9645\u901f\u9012"},{"delivery_id":"XC","delivery_name":"\u4e30\u7a0b\u7269\u6d41"},{"delivery_id":"XB","delivery_name":"\u65b0\u90a6\u7269\u6d41"},{"delivery_id":"FU","delivery_name":"\u5bcc\u53cb"},{"delivery_id":"EBON","delivery_name":"\u4e00\u90a6"},{"delivery_id":"FJFY","delivery_name":"\u98de\u8fdc\uff08\u798f\u5efa\uff09"},{"delivery_id":"SZFY","delivery_name":"\u98de\u8fdc\uff08\u6df1\u5733\uff09"},{"delivery_id":"DTW","delivery_name":"\u5927\u7530"},{"delivery_id":"WX","delivery_name":"\u4e07\u8c61"},{"delivery_id":"HFS","delivery_name":"\u65e5\u65e5\u987a\u5bb6\u5c45"},{"delivery_id":"YCT","delivery_name":"\u9ed1\u732b\u5b85\u6025\u4fbf"},{"delivery_id":"CQHYSM","delivery_name":"\u91cd\u5e86\u534e\u5b87"},{"delivery_id":"JHRSM","delivery_name":"\u4f73\u60e0\u5c14"},{"delivery_id":"WDT","delivery_name":"\u7f51\u7535\u901a"},{"delivery_id":"NFDS","delivery_name":"\u5357\u65b9\u90fd\u5e02"},{"delivery_id":"SCKJ","delivery_name":"\u4e1c\u9a8f"},{"delivery_id":"HWTP","delivery_name":"\u5fae\u7279\u6d3e\uff08\u6e56\u5317\uff09"},{"delivery_id":"HB","delivery_name":"\u534e\u535a"},{"delivery_id":"TDSM","delivery_name":"\u5357\u5b81\u817e\u8fbe\u878d\u8054"},{"delivery_id":"TWTP","delivery_name":"\u5fae\u7279\u6d3e\uff08\u5929\u6d25\uff09"},{"delivery_id":"NJCB","delivery_name":"\u665f\u90a6\u7269\u6d41"},{"delivery_id":"UCS","delivery_name":"UCS\u5408\u4f17\u901f\u9012"},{"delivery_id":"GTO","delivery_name":"\u56fd\u901a\u5feb\u9012"},{"delivery_id":"EMS","delivery_name":"EMS"},{"delivery_id":"GZFY","delivery_name":"\u51e1\u5b87\u901f\u9012"},{"delivery_id":"WJ","delivery_name":"\u65e0\u7586\u7269\u6d41"},{"delivery_id":"JUMEI","delivery_name":"\u805a\u7f8e\u4f18\u54c1"},{"delivery_id":"SXFY","delivery_name":"\u98de\u8fdc\uff08\u9655\u897f\uff09"},{"delivery_id":"DYKDB","delivery_name":"\u6ec7\u9a7f\u5feb\u9012"},{"delivery_id":"WTPSM","delivery_name":"\u5fae\u7279\u6d3e\uff08\u4e0a\u6d77\uff09"},{"delivery_id":"WB","delivery_name":"\u4e07\u535a\u5feb\u9012"},{"delivery_id":"FEDEXLY","delivery_name":"\u8054\u90a6\u5feb\u9012\u9646\u8fd0"},{"delivery_id":"WHFYSM","delivery_name":"\u98de\u8fdc\uff08\u6b66\u6c49\uff09"},{"delivery_id":"PJ","delivery_name":"\u54c1\u9a8f\u7269\u6d41"},{"delivery_id":"JSJSD","delivery_name":"\u91d1\u901f\u91d1\u901f\u9012"},{"delivery_id":"HOMEVV","delivery_name":"\u4e3a\u4e3a\u7f51"},{"delivery_id":"BJCS","delivery_name":"\u57ce\u5e02100"},{"delivery_id":"HH","delivery_name":"\u6d77\u7ea2\u7f51\u9001"},{"delivery_id":"SDKX","delivery_name":"\u51ef\u65cb\u65f6\u4ee3"},{"delivery_id":"LXN","delivery_name":"\u84dd\u7280\u725b"},{"delivery_id":"KYD","delivery_name":"\u5feb\u4f18\u8fbe\u901f\u9012"},{"delivery_id":"YZ","delivery_name":"\u71d5\u8d75\u90fd\u5e02"},{"delivery_id":"HL","delivery_name":"\u5b8f\u8054\u901f\u9012"},{"delivery_id":"HZRB","delivery_name":"\u6bcf\u65e5\u9001"},{"delivery_id":"DFH","delivery_name":"\u4e1c\u65b9\u6c47"},{"delivery_id":"YUD","delivery_name":"\u957f\u53d1"},{"delivery_id":"HDT","delivery_name":"\u6c47\u9012\u901a"},{"delivery_id":"dangdang","delivery_name":"\u5f53\u5f53"},{"delivery_id":"HFHW","delivery_name":"\u6c47\u6587"},{"delivery_id":"MSKD","delivery_name":"\u8499\u901f\u5feb\u9012"},{"delivery_id":"QRT","delivery_name":"\u5168\u65e5\u901a\u5feb\u9012"},{"delivery_id":"HY","delivery_name":"\u5929\u5730\u534e\u5b87"},{"delivery_id":"JKLSD","delivery_name":"\u79ef\u5ba2\u83b1\u901f\u9012"},{"delivery_id":"JXW","delivery_name":"\u9152\u4ed9\u7f51"},{"delivery_id":"YMJSM","delivery_name":"\u8a89\u7f8e\u6377"},{"delivery_id":"GHS","delivery_name":"\u73af\u7403\u8d2d\u7269"},{"delivery_id":"HTTY","delivery_name":"\u6052\u6cf0\u901a\u6e90\u7269\u6d41"},{"delivery_id":"ANE56","delivery_name":"\u5b89\u80fd\u7269\u6d41"},{"delivery_id":"JIAYU","delivery_name":"\u4f73\u5b87\u7269\u6d41"},{"delivery_id":"LJS","delivery_name":"\u7acb\u5373\u9001"},{"delivery_id":"YTD","delivery_name":"\u6613\u901a\u8fbe"},{"delivery_id":"HMJ","delivery_name":"\u7ea2\u9a6c\u7532"},{"delivery_id":"UNIPS","delivery_name":"\u53d1\u7f51"},{"delivery_id":"ADX","delivery_name":"\u5b89\u8fbe\u4fe1"},{"delivery_id":"YC","delivery_name":"\u8fdc\u957f"},{"delivery_id":"JIAYI","delivery_name":"\u4f73\u6021\u7269\u6d41"},{"delivery_id":"MSD","delivery_name":"\u654f\u601d\u8fbe"},{"delivery_id":"JSYG","delivery_name":"\u4e91\u67dc"},{"delivery_id":"BJFKD","delivery_name":"\u98de\u5eb7\u8fbe\u901f\u8fd0"},{"delivery_id":"FPXSZ","delivery_name":"\u9012\u56db\u65b9"},{"delivery_id":"YCGWL","delivery_name":"\u8fdc\u6210\u7269\u6d41"},{"delivery_id":"DWD","delivery_name":"\u70b9\u6211\u8fbe"},{"delivery_id":"QFKD","delivery_name":"\u5168\u5cf0\u5feb\u9012"},{"delivery_id":"YTO","delivery_name":"\u5706\u901a\u901f\u9012"},{"delivery_id":"YUNDA","delivery_name":"\u97f5\u8fbe\u5feb\u9012"},{"delivery_id":"ROKIN","delivery_name":"\u8363\u5e86\u7269\u6d41"},{"delivery_id":"YT","delivery_name":"\u4e00\u7edf\u98de\u9e3f"},{"delivery_id":"SZYJ","delivery_name":"\u987a\u6377\u4e30\u8fbe"},{"delivery_id":"SDY","delivery_name":"\u901f\u9012\u6613"},{"delivery_id":"STO","delivery_name":"\u7533\u901a\u5feb\u9012"},{"delivery_id":"JH","delivery_name":"\u5efa\u534e"},{"delivery_id":"BWTP","delivery_name":"\u5fae\u7279\u6d3e\uff08\u5317\u4eac\uff09"},{"delivery_id":"JX","delivery_name":"\u54c8\u5c14\u6ee8\u6377\u8baf"},{"delivery_id":"TL","delivery_name":"\u901a\u8def"},{"delivery_id":"CDYB","delivery_name":"\u6613\u6cca"},{"delivery_id":"CCD","delivery_name":"\u6b21\u6668\u8fbe\uff08\u90d1\u5dde\uff09"},{"delivery_id":"DHL","delivery_name":"\u4e2d\u5916\u8fd0\u6566\u8c6a"},{"delivery_id":"UAPEX","delivery_name":"\u5168\u4e00\u5feb\u9012"},{"delivery_id":"SS","delivery_name":"\u95ea\u9001"},{"delivery_id":"TYWL","delivery_name":"\u5929\u97f3\u7269\u6d41"},{"delivery_id":"FAST","delivery_name":"\u5feb\u6377\u901f\u9012"},{"delivery_id":"SY","delivery_name":"\u9996\u4e1a"},{"delivery_id":"CQFJ","delivery_name":"\u91cd\u5e86\u5bcc\u5409"},{"delivery_id":"139kd","delivery_name":"139\u5feb\u9012"},{"delivery_id":"CNEX","delivery_name":"\u4f73\u5409\u5feb\u8fd0"},{"delivery_id":"XHM","delivery_name":"\u5c0f\u7ea2\u5e3d"},{"delivery_id":"GZSM","delivery_name":"\u601d\u8fc8\u901f\u9012"},{"delivery_id":"XHH","delivery_name":"\u65b0\u534e\u8d6b"},{"delivery_id":"CZ","delivery_name":"\u8bda\u4e2d\u7269\u6d41"},{"delivery_id":"CY","delivery_name":"\u521b\u4e00\uff08\u6e56\u5357\uff09"},{"delivery_id":"SF","delivery_name":"\u987a\u4e30\u901f\u8fd0"},{"delivery_id":"EYB","delivery_name":"EMS\u7ecf\u6d4e\u5feb\u9012"},{"delivery_id":"KR","delivery_name":"\u5bbd\u5bb9"},{"delivery_id":"CJWL","delivery_name":"\u57ce\u9645\u7269\u6d41\uff08\u5929\u6d25\uff09"},{"delivery_id":"SJ","delivery_name":"\u901f\u6377\u5feb\u9012"},{"delivery_id":"KBWKD","delivery_name":"\u5feb\u5b9d\uff08\u5fae\u5feb\u9012\uff09"},{"delivery_id":"DBL","delivery_name":"\u5fb7\u90a6"},{"delivery_id":"ZYKY","delivery_name":"\u4e2d\u8c0a\u5feb\u8fd0"},{"delivery_id":"LTS","delivery_name":"\u8054\u660a\u901a"},{"delivery_id":"GGHZ","delivery_name":"\u9b54\u683c"},{"delivery_id":"RRKD","delivery_name":"\u4eba\u4eba\u5feb\u9012"},{"delivery_id":"SHCOD","delivery_name":"\u8d5b\u6fb3\u9012"},{"delivery_id":"HCT","delivery_name":"\u6c47\u8bda\u901a\u7269\u6d41"},{"delivery_id":"RRSLJ","delivery_name":"\u65e5\u65e5\u987a\u4e50\u5bb6"},{"delivery_id":"POST","delivery_name":"\u4e2d\u56fd\u90ae\u653f\u5e73\u90ae"},{"delivery_id":"SFT","delivery_name":"\u5341\u65b9\u901a\u8d27\u8fd0"},{"delivery_id":"LB","delivery_name":"\u9f99\u90a6\u901f\u9012"},{"delivery_id":"CRE","delivery_name":"\u4e2d\u94c1\u5feb\u8fd0"},{"delivery_id":"HXGW","delivery_name":"\u597d\u4eab\u8d2d\u7269"},{"delivery_id":"XFWL","delivery_name":"\u4fe1\u4e30\u7269\u6d41"},{"delivery_id":"OZZO","delivery_name":"\u5965\u7855\u7269\u6d41"},{"delivery_id":"CL","delivery_name":"\u57ce\u8054\u901f\u9012"},{"delivery_id":"TTKDEX","delivery_name":"\u5929\u5929\u5feb\u9012"},{"delivery_id":"CAIN","delivery_name":"\u83dc\u9e1f"},{"delivery_id":"KY","delivery_name":"\u8de8\u8d8a\u901f\u8fd0"},{"delivery_id":"ZTOKY","delivery_name":"\u4e2d\u901a\u5feb\u8fd0"},{"delivery_id":"XLKD","delivery_name":"\u559c\u6765\u5feb\u9012"},{"delivery_id":"HLL","delivery_name":"\u8d27\u62c9\u62c9"},{"delivery_id":"CNDTK","delivery_name":"\u627f\u8bfa\u8fbe\u7279\u5feb"},{"delivery_id":"SHSQ","delivery_name":"\u5b9e\u60e0\u90ae\u5c40"},{"delivery_id":"DBKD","delivery_name":"\u5fb7\u90a6\u5feb\u9012"},{"delivery_id":"LXNBJ","delivery_name":"\u84dd\u7280\u725b\u642c\u5bb6"},{"delivery_id":"KBWL","delivery_name":"\u5fae\u5feb\u9012"},{"delivery_id":"sssj","delivery_name":"\u95ea\u9001\u5546\u5bb6\u7248"},{"delivery_id":"UU","delivery_name":"UU\u8dd1\u817f"},{"delivery_id":"KDCS","delivery_name":"\u5feb\u9012\u8d85\u5e02"},{"delivery_id":"SNKD","delivery_name":"\u82cf\u5b81\u5feb\u9012"},{"delivery_id":"SNWL","delivery_name":"\u82cf\u5b81\u5feb\u9012"},{"delivery_id":"KGDC","delivery_name":"\u5feb\u72d7\u6253\u8f66"},{"delivery_id":"BEST","delivery_name":"\u767e\u4e16\u5feb\u9012"},{"delivery_id":"CNXC","delivery_name":"\u83dc\u9e1f\u4e61\u6751"},{"delivery_id":"ALIBABA","delivery_name":"\u963f\u91cc\u5df4\u5df4"},{"delivery_id":"DADA","delivery_name":"\u8fbe\u8fbe"},{"delivery_id":"BESTPS","delivery_name":"\u767e\u4e16\u9a7f\u7ad9"},{"delivery_id":"KBPS","delivery_name":"\u5feb\u5b9d\u9a7f\u7ad9"},{"delivery_id":"SFISTD","delivery_name":"\u987a\u4e30\u540c\u57ce"},{"delivery_id":"TXPS","delivery_name":"\u5154\u559c\u9a7f\u7ad9"},{"delivery_id":"kuaidi100","delivery_name":"\u5feb\u9012100"},{"delivery_id":"QM","delivery_name":"\u5de7\u76ee\u5feb\u9012\u67dc"},{"delivery_id":"JD","delivery_name":"\u4eac\u4e1c"},{"delivery_id":"zhongyouwuliu","delivery_name":"\u4e2d\u90ae\u7269\u6d41"},{"delivery_id":"YJYPS","delivery_name":"\u9a7f\u52a0\u6613\u9a7f\u7ad9"},{"delivery_id":"XMPS","delivery_name":"\u718a\u732b\u9a7f\u7ad9"},{"delivery_id":"HMPS","delivery_name":"\u6b22\u732b\u9a7f\u7ad9"},{"delivery_id":"KDM","delivery_name":"\u5feb\u9012\u732b"},{"delivery_id":"JT","delivery_name":"\u6781\u5154\u901f\u9012"},{"delivery_id":"FENGWANG","delivery_name":"\u4e30\u7f51\u901f\u8fd0"},{"delivery_id":"zmkmkd","delivery_name":"\u4e39\u9e1fKD"},{"delivery_id":"kke","delivery_name":"\u4eac\u5e7f\u901f\u9012"},{"delivery_id":"HUANGMAJIA","delivery_name":"\u9ec4\u9a6c\u7532\u5feb\u9012"},{"delivery_id":"disu","delivery_name":"D\u901f"},{"delivery_id":"RRS","delivery_name":"\u65e5\u65e5\u987a\u7269\u6d41"},{"delivery_id":"ymdd","delivery_name":"\u58f9\u7c73\u6ef4\u7b54"}] \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Aliapp.php b/addon/aliapp/shop/controller/Aliapp.php deleted file mode 100644 index 5658032..0000000 --- a/addon/aliapp/shop/controller/Aliapp.php +++ /dev/null @@ -1,227 +0,0 @@ -replace = [ - 'WEAPP_CSS' => __ROOT__ . '/addon/weapp/shop/view/public/css', - 'WEAPP_JS' => __ROOT__ . '/addon/weapp/shop/view/public/js', - 'WEAPP_IMG' => __ROOT__ . '/addon/weapp/shop/view/public/img', - 'WEAPP_SVG' => __ROOT__ . '/addon/weapp/shop/view/public/svg', - ]; - } - - /*** - * 小程序设置 - * @return mixed - */ - public function setting() - { - $config = new Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $this->assign("config_info", $config_info); - return $this->fetch('aliapp/setting', [], $this->replace); - } - - /*** - * 小程序配置 - * @return array|mixed - */ - public function config() - { - $config = new Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - if (request()->isAjax()) { - $appid = input('appid', ''); - $qrcode = input('qrcode', ''); - $app_name = input('app_name', ''); - $app_original = input('app_original', ''); - $alipay_public = input('alipay_public_key', ''); - $private_key = input('private_key', ''); - $public_key = input('public_key', ''); - $data = array( - 'line_type' => input('line_type', 'custom'), - "appid" => $appid, - 'app_name' => $app_name, - 'qrcode' => $qrcode, - 'alipay_public_key' => $alipay_public, - 'private_key' => $private_key, - 'public_key' => $public_key, - 'app_original' => $app_original, - ); - $data = array_merge($config_info, $data); - $res = $config->setAlipayConfig($appid, $data, $this->site_id, $app_original); - return $res; - } else { - $app = new MinCode($this->site_id); - $url = addon_url('aliapp/shop/auth/authinfo', ['state' => 'minapp']); - $auth_url = $app->getPreAuthorizationUrl($url); - $this->assign('auth_url', $auth_url); - $this->assign("config_info", $config_info); - $this->assign("line_type", $config_info['line_type'] ?? 'custom'); - return $this->fetch('aliapp/config', [], $this->replace); - } - } - - - /*** - * 授权接入 - * @return mixed - */ - public function auth() - { - $app = new MinCode(); - $url = addon_url('aliapp/shop/auth/authinfo'); - $ag_site_id = model('site')->getValue(['site_id' => $this->site_id], 'agent_id'); - $text = $this->site_id . '|minapp|' . $ag_site_id; - $auth_url = $app->getminiAuthorizationUrl($url, url_safe_base64_encode($text)); - $qrcode_name = $this->site_id.'alipay_auth'; - $path = 'upload/qrcode'; - qrcode($auth_url, $path, $qrcode_name); - $this->assign('auth_img', '/' . $path . '/' . $qrcode_name . '.png'); - return $this->fetch('aliapp/auth', [], $this->replace); - } - - - /** - * 编辑小程序基础信息 - * 已商上架小程序无法再次修改 - * @return array|mixed - */ - public function editapp() - { - $app = new MinCode(); - $config = new Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $app->appAuthToken = $config_info['app_auth_token']; - if (request()->isAjax()) { - $data=request()->post(); - $config_info['app_name']=$data['app_name']; - $config_info['head_img']=$data['app_logo']; - $app_original=$config_info['app_original']; - $data['app_logo']= ROOT_PATH.'/'.$data['app_logo']; - $app_logo=$data['app_logo']; - unset($data['category_ids'],$data['file'],$data['app_logo']); - $res=$app->miniSetBaseinfo($data,$app_logo); //设置小 - if($res['code']=='10000'){ - $config_info['is_baseinfo']=1; - $config_info['service_phone']=$data['service_phone']; - $config->setAlipayConfig($config_info['appid'],$config_info,$this->site_id,$app_original); - cache($app->appAuthToken . '_baseinfo',null); - $message='设置成功'; - }else{ - $message=$res['sub_msg']; - } - return success(0,$message,$res); - } - $baseinfo = cache($app->appAuthToken . '_baseinfo'); - if (empty($baseinfo)) { - $baseinfo = $app->requestApi('alipay.open.mini.baseinfo.query')['alipay_open_mini_baseinfo_query_response']; - if($baseinfo['code']==10000){ - cache($app->appAuthToken . '_baseinfo', $baseinfo); - }else{ - cache($app->appAuthToken . '_baseinfo', null); - $this->error($baseinfo['sub_msg']); - } - } - $one_category = []; - $category = $app->requestApi('alipay.open.mini.category.query', ['is_filter' => true])['alipay_open_mini_category_query_response']; - if ($category['mini_category_list']) { - $category_all = array_column($category['mini_category_list'], null, 'category_id'); - foreach ($category_all as $key => $item) { - if ($item['parent_category_id'] == '0') { - $one_category[] = $item; - } - } - cache($app->appAuthToken . '_category', $one_category); - cache($app->appAuthToken . '_alls_category', $category_all); - } - $original = []; - $mini_category_ids = []; - if(isset($baseinfo['category_names'])){ - $category_names = $baseinfo['category_names']; - $category_ids = explode(';', $category_names); - $category_all_name = array_column($category_all, null, 'category_name'); - foreach ($category_ids as $key => $val) { - if ($val) { - $text = explode('_', $val); - foreach ($text as $category_namet) { - $d=$category_all_name[$category_namet]??[]; - if($d){ - $d['checked']=true; - $category_all[$d['category_id']]['checked']=true; - $original[$key][] = $d; - } - } - } - } - } - if ($original) { //已设置分类 - foreach ($original as $value) { - $category_ids = array_column($value, 'category_id'); - $mini_category_ids[] = implode('_', $category_ids); - } - } - if (isset($baseinfo['app_logo'])&&strpos($baseinfo['app_logo'], 'http')===0){ - $upload=new UploadModel($this->site_id); - $pic_img=$upload->setPath("common/images/" . date("Ymd") . '/')->remotePullToLocal($baseinfo['app_logo']); - $baseinfo['app_logo']=$pic_img['data']['path']; - } - $this->assign("original", $original); - $this->assign("allCategory", $this->getTreeCategory($category_all)); - $this->assign("info", $baseinfo); - $this->assign("mini_category_ids", implode(';', $mini_category_ids)); - return $this->fetch('aliapp/aliapp_edit', [], $this->replace); - } - - - /*** - * 获取小程序分类 - * @return mixed|void - */ - public function getMinicategory() - { - if (request()->isAjax()) { - $config = new Config(); - $category_id = input('category_id'); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $appAuthToken = $config_info['app_auth_token']; - $category_all = cache($appAuthToken . '_alls_category'); - $category = []; - if($category_id==''){ - $one_category = cache($appAuthToken . '_category'); - return $one_category; - } - foreach ($category_all as $key => $item) { - if ($item['parent_category_id'] == $category_id) { - $category[] = $item; - } - } - return $category; - } - } - - public function getTreeCategory($category){ - $category_all=$category; - $res = []; - //遍历寻父 O(n) - foreach ($category_all as &$item) { - if (isset($category_all[$item['parent_category_id']])){ - //注意下面有一个引用符 & ! - $category_all[$item['parent_category_id']]['child'] []= &$item; - }elseif(!$item['parent_category_id']){ // 此处判断是否加入到结果集 $item['pid'] === null 或者 $item['pid'] == -1 之类的 - $res []= &$item; - } - } - unset($item); - return $res; - } -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/AppletRelease.php b/addon/aliapp/shop/controller/AppletRelease.php deleted file mode 100644 index 8cf04b5..0000000 --- a/addon/aliapp/shop/controller/AppletRelease.php +++ /dev/null @@ -1,90 +0,0 @@ -isGet()) $this->forthMenu(); - } - - /** - * Common: 进入发布小程序 - * Author: wu-hui - * Time: 2023/01/03 17:05 - * @return array|mixed - * @throws \think\db\exception\DbException - */ - public function index(){ - if(request()->isAjax()){ - $this->versionsynchronization(); - return (new appletReleaseModel($this->site_id))->getList(); - } - $config = new Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $baseinfo=[]; - $is_baseinfo=1; - if(!empty($config_info['line_type'])&&$config_info['line_type']=='auth'){ - $app = new MinCode($this->site_id); - $app->appAuthToken = $config_info['app_auth_token']; - $baseinfo = cache($app->appAuthToken . '_baseinfo'); - if (empty($baseinfo)) { - $baseinfo = $app->requestApi('alipay.open.mini.baseinfo.query')['alipay_open_mini_baseinfo_query_response']; - cache($app->appAuthToken . '_baseinfo', $baseinfo); - } - if(!isset($baseinfo['category_names'])){ - $is_baseinfo=0; - } - } - $AliPayApplet=new AliPayApplet($this->site_id); - $version = (string)config('alipay.templateInfo.template_version');// 当前系统版本 - $userVer=$AliPayApplet->newestVersion(); - $this->assign('userVersion',$userVer); - $this->assign('is_baseinfo',$is_baseinfo); - $this->assign('baseinfo',$baseinfo); - $this->assign('version',$version); - // 最新版本 - $this->assign('isNewest',version_compare($version, $userVer, '>')); - return $this->fetch('release/index'); - } - - /** - * Common: 小程序发布流程处理 - * Author: wu-hui - * Time: 2023/01/04 11:05 - * @return array - */ - public function publishingProcessProcessing(){ - // 参数获取 - $type = (string)input('type'); - $id = (int)input('id'); - $app_version = input('app_version',''); - return (new AliPayApplet($this->site_id))->publishingInit($type,$id,$app_version); - } - /** - * Common: 版本管理 —— 版本同步 - * Author: wu-hui - * Time: 2022/12/30 10:08 - * @return array - * @throws \Exception - */ - public function versionSynchronization(){ - return (new AliPayApplet($this->site_id))->versionSynchronization(); - } - /** - * Common: 生成小程序推广二维码 - * Author: wu-hui - * Time: 2023/01/03 14:13 - * @return array - */ - public function qrcodeCreate(){ - $version=config('alipay.templateInfo.template_version'); - return (new AliPayApplet($this->site_id))->queryTestQrcode($version); - } -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Auth.php b/addon/aliapp/shop/controller/Auth.php deleted file mode 100644 index 71c1912..0000000 --- a/addon/aliapp/shop/controller/Auth.php +++ /dev/null @@ -1,108 +0,0 @@ -where('site_id', '=', $site_id)->value('agent_id'); - } else { - $this->error('会员信息无效', url("shop/login/login")); - } - } - $authinfo = $openPlatform->handleAuthorize($authCode); - file_put_contents('auth.txt',json_encode($authinfo)); - if (isset($authinfo['code']) && $authinfo['code'] == 10000) { - $token = current($authinfo['tokens']); - switch ($type) { - case 'minapp': - $paydata = [ - 'line_type' => 'auth', - 'app_type' => 'aliapp', - 'site_id' => $site_id ?? 0, - 'ag_site_id' => $ag_site_id ?? 0, - 'appid' => $token['auth_app_id'], - 'appsecret' => '', - 'token' => '', - 'app_name' => '', - 'head_img' => '', - 'qrcode' => '', - 'account' => $token['user_id'], - 'alipay_public' => '', - 'private_key' => '', - 'app_auth_token' => $token['app_auth_token'], - 'app_refresh_token' => $token['app_refresh_token'], - 'app_original' => $token['user_id'], - 'original_values' => $token, - ]; - cache($state_base64, 'yes'); - $paydata['state'] = $state; - event('MiniappAuthInfo', $paydata); - if ($site_id) { - $minapp = new Config(); - $minapp->setAlipayConfig($token['auth_app_id'], $paydata, $site_id, $paydata['app_original']); - } - $this->assign('desc', '授权成功'); - $this->assign('img', 'success'); - return $this->fetch('aliapp/success'); - case 'all': - break; - default; - $paydata = [ - 'appid' => $authinfo['auth_app_id'], - 'appsecret' => '', - 'user_id' => $token['user_id'], - 'app_auth_token' => $authinfo['app_auth_token'], - 'app_refresh_token' => $authinfo['app_refresh_token'], - 'public_key' => '', - 'private_key' => '', - 'alipay_public_key' => '', - 'is_isp' => 1, - 'transfer_status' => 1, - 'refund_status' => 1, - 'pay_status' => 1, - ]; - $config = new Config(); - $config->setAlipayConfig($authinfo['auth_app_id'], $paydata, $site_id); - return $this->success('授权成功', addon_url('aliapp/shop/aliapp/setting')); - } - } else { - return $this->error('授权失败', addon_url('aliapp/shop/aliapp/setting')); - } - } else { - return $this->error('授权失败', addon_url('aliapp/shop/aliapp/setting')); - } - } -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/CreateApplet.php b/addon/aliapp/shop/controller/CreateApplet.php deleted file mode 100644 index 4ea9919..0000000 --- a/addon/aliapp/shop/controller/CreateApplet.php +++ /dev/null @@ -1,41 +0,0 @@ -isGet()) $this->forthMenu(); - } - - /** - * Common: 添加小程序 - * Author: wu-hui - * Time: 2022/12/28 18:16 - * @return mixed - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function index(){ - $createAppletModel = new createAppletModel(); - if (request()->isAjax()) { - // 参数获取 - $info = input('info',[]); - $res = $createAppletModel->setNewParams($info,$this->site_id); - - return $res; - } else { - [$id,$content] = $createAppletModel->getNewParams($this->site_id); - $this->assign('id',$id); - $this->assign('info',$content); - - return $this->fetch('aliapp/createApplet'); - } - } - -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Member.php b/addon/aliapp/shop/controller/Member.php deleted file mode 100644 index e85c42f..0000000 --- a/addon/aliapp/shop/controller/Member.php +++ /dev/null @@ -1,81 +0,0 @@ - 'DEVELOPER', - 1 => 'EXPERIENCER', - 'DEVELOPER' => '开发者', - 'EXPERIENCER' => '体验者', - ]; - - - - public function __construct(){ - parent::__construct(); - - // 输出菜单 - if(request()->isGet()) $this->forthMenu(); - } - - - /** - * Common: 进入成员管理 - * Author: wu-hui - * Time: 2022/12/30 13:53 - * @return array|mixed - * @throws \think\db\exception\DbException - */ - public function index(){ - if(request()->isAjax()) return (new AliPayMember($this->site_id))->getList(); - - return $this->fetch('member/index'); - } - /** - * Common: 同步成员 - * Author: wu-hui - * Time: 2022/12/30 13:47 - * @return array - */ - public function synchronization(){ - // 参数获取 - $type = (int)input('type'); - - return (new AliPayMember($this->site_id))->synchronizationMember($this->memberRole[$type]); - } - /** - * Common: 添加成员 - * Author: wu-hui - * Time: 2022/12/30 14:28 - * @return array|mixed - */ - public function addMember(){ - if (request()->isAjax()) { - - return (new AliPayMember($this->site_id))->addMember(); - } else { - - return $this->fetch('member/add'); - } - } - /** - * Common: 删除成员 - * Author: wu-hui - * Time: 2022/12/30 14:41 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function delMember(){ - - return (new AliPayMember($this->site_id))->delMember(); - } - - -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Message.php b/addon/aliapp/shop/controller/Message.php deleted file mode 100644 index a15e86f..0000000 --- a/addon/aliapp/shop/controller/Message.php +++ /dev/null @@ -1,122 +0,0 @@ -isAjax()) { - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $condition = array( - ["support_type", "like", '%aliapp%'], - ); - $list = $message_model->getMessagePageList($condition, $this->site_id, $page, $page_size); - return $list; - } else { -// $config_model = new Config(); -// $config = $config_model->getTemplateMessageConfig($this->site_id); -// $this->assign('config', $config['data']['value']); - return $this->fetch('message/config'); - } - } - - - public function edit() - { - $message_model = new MessageModel(); - $keywords = input("keywords", ""); - $info_result = $message_model->getMessageInfo($this->site_id, $keywords); - $info = $info_result["data"]; - $aliapp_json_array = $info["aliapp_json_array"]; - if (isset($info["aliapp_json"]) && $info["aliapp_json"]) { - $aliapp_json_array = array_merge($aliapp_json_array, json_decode($info["aliapp_json"], true)); - } - $aliapp_json_array['template_id'] = $aliapp_json_array['template_id'] ?? ''; - $aliapp_json_array['content'] = $aliapp_json_array['content'] ?? ''; - if (request()->isAjax()) { - if (empty($info)) - return error("", "不存在的模板信息!"); - $aliapp_is_open = input('aliapp_is_open', 0); - $aliapp_json_array['template_id'] = input('template_id'); - $res = $message_model->editMessage( - ['aliapp_is_open' => $aliapp_is_open, - 'site_id' => $this->site_id, - 'keywords' => $keywords, - 'aliapp_json' => json_encode($aliapp_json_array)], - [ - ["keywords", "=", $keywords], - ['site_id', '=', $this->site_id], - ]); - return $res; - } else { - if (empty($info)) $this->error("不存在的模板信息!"); - $this->forthMenu(); - $this->assign("msglist", $this->MsgList($keywords)); - $this->assign("merchant_biz_type", $aliapp_json_array['template_id']); - $this->assign("keywords", $keywords); - $this->assign("info", $aliapp_json_array); - $this->assign('aliapp_is_open', $info['aliapp_is_open']); - return $this->fetch('message/edit'); - } - } - - /*** - * 设置订单动态消息 - * @return void - */ - public function orderMsg() - { - echo '开发中'; - } - - public function MsgList($type) - { - $arr['ORDER_PAY'] = [ - 'KX_SHOPPING' => '电商实物', - 'VIRTUAL_GOODS_ORDER' => '虚拟商品', - 'COMMUNITY_GROUP' => '社区团购', - 'KX_TAKE_OUT' => '送货到家', - 'KX_SELF_PICK' => '上门自提', - 'CYCLE_ORDER' => '周期订购', - ]; - $arr['ORDER_DELIVERY'] = $arr['ORDER_PAY']; - return $arr[$type] ?? []; - } - - - public function defaultTemplate($keywords) - { - $arr = [ - 'ORDER_PAY' => 'KX_SHOPPING', - 'VERIFY' => 'KX_SHOPPING', - ]; - return $arr[$keywords] ?? ''; - } - - /** - * Common: 默认模板内容 - * Author: wu-hui - * Time: 2023/01/10 10:41 - * @param $keywords - * @return array|string - */ - private function defaultMessageContent($keywords) - { - $list = [ - 'ORDER_PAY' => "下单时间:\n订单编号:\n商品名称{{thing4.DATA}}\n订单金额:", - 'VERIFY' => "核销产品:{{keyword1}}\n核销商户:{{keyword2}}\n核销时间:{{keyword3}}\n", - 'INTEREST_EXPIRATION_NOTICE' => "商家名称:{{keyword1}}\n剩余次数:{{keyword2}}\n优惠内容:{{keyword3}}\n", - 'SERVICE_OPENED_SUCCESS' => "到期时间:{{keyword1}}\n姓名:{{keyword2}}\n开通时间:{{keyword3}}\n服务项目:{{keyword4}}\n", - ]; - return $list[$keywords] ?? []; - } -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Order.php b/addon/aliapp/shop/controller/Order.php deleted file mode 100644 index 41ebb84..0000000 --- a/addon/aliapp/shop/controller/Order.php +++ /dev/null @@ -1,45 +0,0 @@ -isAjax()) { - $Trade = new TradeComplain(); - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $condition = [ - 'page_num' => $page, - 'page_size' => $page_size, - ]; - $settle_status = input('settle_status', ''); - $begin_time = input('begin_time'); - $end_time = input('end_time'); - if ($begin_time && $end_time) { - $condition['begin_time'] = $begin_time; - $condition['end_time'] = $end_time; - } - if ($settle_status) { - $condition['status'] = $settle_status; - } - $data = $Trade->getBatchquery($condition, $this->site_id); - return $data; - } - return $this->fetch('order/tradecomplain'); - } - - - public function complaindetail() - { - - - } -} \ No newline at end of file diff --git a/addon/aliapp/shop/controller/Pay.php b/addon/aliapp/shop/controller/Pay.php deleted file mode 100644 index 56ac822..0000000 --- a/addon/aliapp/shop/controller/Pay.php +++ /dev/null @@ -1,21 +0,0 @@ - -
-
- 小程序基础设置 -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-

10~32个字符,一个中文两个字符。

-
-
- -
- -
-
- {if condition="isset($info.app_logo) && $info.app_logo"} - - {else/} -
- -

点击上传

-
- {/if} -
-
-
- - -
-
点击替换
-
- -
-
-
-

建议上传像素为180*180 px,logo图片最大 2M,图片高度与宽度必须一致

-
-
-
- -
- -
-

20-400个字符,一个中文两个字符。

-
- -
- -
- -
-
-

请填写客服服务真实电话

-

请保持畅通,系统不定期机器人回访,如无法联系会引发系统无法使用、货款冻结

-

个别老王已冻结数十万货款

-
-
-
- -
- -
-
- -
- -
-
-
- -
-
删除
-
- -
-

请设置一个主营分类,最少设置一个分类

-
-
-
- -
- - - -
- -{/block} -{block name="script"} - - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/auth.html b/addon/aliapp/shop/view/aliapp/auth.html deleted file mode 100644 index 6911640..0000000 --- a/addon/aliapp/shop/view/aliapp/auth.html +++ /dev/null @@ -1,46 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
- -
-
-
-
-
- -
-
-
-
-
-
-

请使用支付宝客户端扫码授权

-
- - - -
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/config.html b/addon/aliapp/shop/view/aliapp/config.html deleted file mode 100644 index 1bf750c..0000000 --- a/addon/aliapp/shop/view/aliapp/config.html +++ /dev/null @@ -1,157 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} -{/block} -{block name="main"} -
-
-
- 接入方式 -
-
-
- - -
-
-
设置接入方式
-
-
-
- 开发者设置 -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- {if condition="$config_info && $config_info.qrcode"} - - {else/} -
- -

点击上传

-
- {/if} -
-
-
-
-
-
-
-
- 开发者ID设置 -
-
-
- -
- -
-
-
- -
- -
- -
-
- -
-
- -
- -
-
- -
- -
- -
-
-
- -
-
- -
- -
-
-
-
- - - -
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/createApplet.html b/addon/aliapp/shop/view/aliapp/createApplet.html deleted file mode 100644 index 54676d6..0000000 --- a/addon/aliapp/shop/view/aliapp/createApplet.html +++ /dev/null @@ -1,143 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="main"} -
-
- -
- -
-
-
- -
- -
登录支付宝的邮箱帐号或手机号
-
-
-
- -
- -
-
-
- -
- -
如果是“无主体名称个体工商户”则填[个体户+法人姓名],例如:个体户张三
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
-
-
- -

点击上传

-
-
- - x -
-
-
- -
- - - -
-
- -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/release.html b/addon/aliapp/shop/view/aliapp/release.html deleted file mode 100644 index c790ea0..0000000 --- a/addon/aliapp/shop/view/aliapp/release.html +++ /dev/null @@ -1,237 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
- 支付宝小程序源码上传 -
-
- -
- {if $errcode} -
- -
-

未能获取到服务分类列表 错误编码:{$errcode.errcode}-{$errcode.errmsg}

-

1.如果未添加请到官方添加服务分类 立即添加

-

2.如已添加但依然无法显示 当前API权限不足请重新授权选择所有权限

-

3.如已其他第三方开发平台需要取消后重新授权

-
-
- {/if} -
-
-
- 程序上传 -
-
-
- -
-
- -
-
-
版本库用户自定义,如1.0.1;1.0.2...等
-
-
- -
-
- -
- 版本描述,描述应用场景用途 -
-
-
-
-
- -
-
-{/block} - {block name="script"} - - {/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/setting.html b/addon/aliapp/shop/view/aliapp/setting.html deleted file mode 100644 index bc949ad..0000000 --- a/addon/aliapp/shop/view/aliapp/setting.html +++ /dev/null @@ -1,225 +0,0 @@ -{extend name="app/shop/view/base.html" /} -{block name="resources"} - - -{/block} -{block name="main"} -
-
- 支付宝小程序使用流程 -
-
-
    -
  • -
    - -
    -

    注册小程序应用

    -
  • -
  • - -
  • -
  • -
    - -
    -

    信息完善

    -
  • -
  • - -
  • -
  • -
    - -
    -

    开发

    -
  • -
  • - -
  • -
  • -
    - -
    -

    提交审核

    -
  • -
  • - -
  • -
  • -
    - -
    -

    发布

    -
  • -
-
-
-
-
- 小程序入口 -
- -
- -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/aliapp/success.html b/addon/aliapp/shop/view/aliapp/success.html deleted file mode 100644 index 7c832f3..0000000 --- a/addon/aliapp/shop/view/aliapp/success.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - 支付宝扫码授权 - - - - -
-
-
{$desc}
-
-
- -
-
-
- - - - - \ No newline at end of file diff --git a/addon/aliapp/shop/view/member/add.html b/addon/aliapp/shop/view/member/add.html deleted file mode 100644 index c85a6ab..0000000 --- a/addon/aliapp/shop/view/member/add.html +++ /dev/null @@ -1,78 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="body"} -
-
- -
- -
-
-
- -
- -
-
- -
- - -
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/member/index.html b/addon/aliapp/shop/view/member/index.html deleted file mode 100644 index 9c55991..0000000 --- a/addon/aliapp/shop/view/member/index.html +++ /dev/null @@ -1,156 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="main"} - -
-
- - - -
-
-
- -
- - -{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/message/config.html b/addon/aliapp/shop/view/message/config.html deleted file mode 100644 index fbc6b1b..0000000 --- a/addon/aliapp/shop/view/message/config.html +++ /dev/null @@ -1,221 +0,0 @@ -{extend name="app/shop/view/base.html" /} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    - - -
-
-
-
- - - - - - - - - - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/message/edit.html b/addon/aliapp/shop/view/message/edit.html deleted file mode 100644 index be87ee5..0000000 --- a/addon/aliapp/shop/view/message/edit.html +++ /dev/null @@ -1,87 +0,0 @@ -{extend name="app/shop/view/base.html" /} -{block name="main"} -
-
- -
- -
-
- -
- -
- -
-
- - {if $msglist} -
- -
- {foreach $msglist as $k => $v} - - {/foreach} -
-
-
- {/if} - -
- -
- -
-
- - -
- - -
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/order/tradecomplain.html b/addon/aliapp/shop/view/order/tradecomplain.html deleted file mode 100644 index 0fd61bf..0000000 --- a/addon/aliapp/shop/view/order/tradecomplain.html +++ /dev/null @@ -1,332 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    -
  • 支付宝交易订单投诉维权
  • -
  • 请在12小时完成售后维权
  • -
-
-
-
-
-
-
-
- -
- - -
-
-
- -
- - -
-
-
-
-
- -
- -
-
-
-
- - -
-
-
-
- -
-
-
-
-
- - - - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/shop/view/public/fail.png b/addon/aliapp/shop/view/public/fail.png deleted file mode 100644 index 5ca1925..0000000 Binary files a/addon/aliapp/shop/view/public/fail.png and /dev/null differ diff --git a/addon/aliapp/shop/view/public/img/alipay_app_new.png b/addon/aliapp/shop/view/public/img/alipay_app_new.png deleted file mode 100644 index 9180086..0000000 Binary files a/addon/aliapp/shop/view/public/img/alipay_app_new.png and /dev/null differ diff --git a/addon/aliapp/shop/view/public/img/alipay_app_select.png b/addon/aliapp/shop/view/public/img/alipay_app_select.png deleted file mode 100644 index c83241a..0000000 Binary files a/addon/aliapp/shop/view/public/img/alipay_app_select.png and /dev/null differ diff --git a/addon/aliapp/shop/view/public/success.png b/addon/aliapp/shop/view/public/success.png deleted file mode 100644 index da3943d..0000000 Binary files a/addon/aliapp/shop/view/public/success.png and /dev/null differ diff --git a/addon/aliapp/shop/view/release/index.html b/addon/aliapp/shop/view/release/index.html deleted file mode 100644 index 6dcdec0..0000000 --- a/addon/aliapp/shop/view/release/index.html +++ /dev/null @@ -1,407 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    -
  • 通过平台注册小程序需要完善基础信息
  • - {if $is_baseinfo==0} -
  • 未完善基础信息将无法通过审核去完善
  • - {/if} -
-
-
- -
-
- {if $isNewest} - - {else/} - - {/if} - - -
-
-
- -
- - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/aliapp/storeapi/controller/AppletRelease.php b/addon/aliapp/storeapi/controller/AppletRelease.php deleted file mode 100644 index bc7fdc0..0000000 --- a/addon/aliapp/storeapi/controller/AppletRelease.php +++ /dev/null @@ -1,200 +0,0 @@ -checkToken(); - if ($token[ 'code' ] < 0) { - echo $this->response($token); - exit; - } - } - /** - * Common: 进入发布小程序 - * Author: wu-hui - * Time: 2023/01/03 17:05 - * @return array|mixed - * @throws \think\db\exception\DbException - */ - public function index(){ - $config = new Config(); - $config_info = $config->getAppConfig($this->site_id)['data']['value']; - $baseinfo=[]; - $is_baseinfo=1; - if(!empty($config_info['line_type'])&&$config_info['line_type']=='auth'){ - $app = new MinCode(); - $app->appAuthToken = $config_info['app_auth_token']; - $baseinfo = cache($app->appAuthToken . '_baseinfo'); - if (empty($baseinfo)) { - $baseinfo = $app->requestApi('alipay.open.mini.baseinfo.query')['alipay_open_mini_baseinfo_query_response']; - cache($app->appAuthToken . '_baseinfo', $baseinfo); - } - if(!isset($baseinfo['category_names'])){ - $is_baseinfo=0; - } - } - return $this->response($this->success([ - 'is_baseinfo' => $is_baseinfo, - 'baseinfo' => $baseinfo, - 'isNewest' => (new AliPayApplet($this->site_id))->isNewestVersion(), - ])); - } - - /** - * 编辑小程序基础信息 - * 已商上架小程序无法再次修改 - * @return array|mixed - */ - public function appinfo() - { - $site_id = $this->site_id; - $app = new MinCode(); - $config = new Config(); - $config_info = $config->getAppConfig($site_id)['data']['value']; - $app->appAuthToken = $config_info['app_auth_token']; - - $baseinfo = cache($app->appAuthToken . '_baseinfo'); - if (empty($baseinfo)) { - $baseinfo = $app->requestApi('alipay.open.mini.baseinfo.query')['alipay_open_mini_baseinfo_query_response']; - cache($app->appAuthToken . '_baseinfo', $baseinfo); - } - $one_category = cache($app->appAuthToken . '_category'); - $category_all = cache($app->appAuthToken . '_alls_category'); - if (empty($one_category)) { - $category = $app->requestApi('alipay.open.mini.category.query', ['is_filter' => true])['alipay_open_mini_category_query_response']; - if ($category['mini_category_list']) { - $category_all = array_column($category['mini_category_list'], null, 'category_id'); - $one_category = []; - foreach ($category_all as $key => $item) { - if ($item['parent_category_id'] == '0') { - $one_category[] = $item; - } - } - cache($app->appAuthToken . '_category', $one_category); - cache($app->appAuthToken . '_alls_category', $category_all); - } - } - - $original = []; - $mini_category_ids = []; - if(isset($baseinfo['category_names'])){ - $category_names = $baseinfo['category_names']; - $category_ids = explode(';', $category_names); - $category_all_name = array_column($category_all, null, 'category_name'); - foreach ($category_ids as $key => $val) { - if ($val) { - $text = explode('_', $val); - foreach ($text as $category_namet) { - $d=$category_all_name[$category_namet]??[]; - if($d){ - $d['checked']=true; - $category_all[$d['category_id']]['checked']=true; - $original[$key][] = $d; - } - } - } - } - } - if ($original) { //已设置分类 - foreach ($original as $value) { - $category_ids = array_column($value, 'category_id'); - $mini_category_ids[] = implode('_', $category_ids); - } - } - if (isset($baseinfo['app_logo'])&&strpos($baseinfo['app_logo'], 'http')===0){ - $upload=new UploadModel($site_id); - $pic_img=$upload->setPath("common/images/" . date("Ymd") . '/')->remotePullToLocal($baseinfo['app_logo']); - $baseinfo['app_logo']=$pic_img['data']['path']; - } - $res = [ - 'original' => $original, - 'allCategory' => $this->getTreeCategory($category_all), - 'info' => $baseinfo, - 'mini_category_ids' => implode(';', $mini_category_ids), - 'app_id_info' => model('uni_account')->getInfo([['site_id', '=', $this->site_id]],'appid'), - 'isNewest' => (new AliPayApplet($this->site_id))->isNewestVersion(), - ]; - return $this->response($this->success($res)); - } - - public function list(){ - $list = (new appletReleaseModel($this->site_id))->getList(); - return $this->response($list); - } - - public function getTreeCategory($category){ - $category_all=$category; - $res = []; - //遍历寻父 O(n) - foreach ($category_all as &$item) { - if (isset($category_all[$item['parent_category_id']])){ - //注意下面有一个引用符 & ! - $category_all[$item['parent_category_id']]['child'] []= &$item; - }elseif(!$item['parent_category_id']){ // 此处判断是否加入到结果集 $item['pid'] === null 或者 $item['pid'] == -1 之类的 - $res []= &$item; - } - } - unset($item); - return $res; - } - - /** - * Common: 小程序发布流程处理 - * Author: wu-hui - * Time: 2023/01/04 11:05 - * @return array|false|string - */ - public function publishingProcessProcessing(){ - // 参数获取 - $type = (string)input('type'); - $id = (int)input('id'); - return $this->response((new AliPayApplet($this->site_id))->publishingInit($type,$id)); - } - /** - * Common: 版本管理 —— 版本同步 - * Author: wu-hui - * Time: 2022/12/30 10:08 - * @return array|false|string - * @throws \Exception - */ - public function versionSynchronization(){ - return $this->response((new AliPayApplet($this->site_id))->versionSynchronization()); - } - /** - * Common: 生成小程序推广二维码 - * Author: wu-hui - * Time: 2023/01/03 14:13 - * @return array|false|string - */ - public function qrcodeCreate(){ - $version=config('alipay.templateInfo.template_version'); - return $this->response((new AliPayApplet($this->site_id))->queryTestQrcode($version)); - } - -} \ No newline at end of file diff --git a/addon/alilife/config/diy_view.php b/addon/alilife/config/diy_view.php deleted file mode 100644 index 917ab1e..0000000 --- a/addon/alilife/config/diy_view.php +++ /dev/null @@ -1,30 +0,0 @@ - '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ] - 'template' => [], - // 后台自定义组件——装修 - 'util' => [], - // 自定义页面路径 - 'link' => [ ], - // 自定义图标库 - 'icon_library' => [], - // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件 - 'component' => [], - // uni-app 页面,多个逗号隔开 - 'pages' => [], - // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述' - 'info' => [], - // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】 - 'theme' => [], - // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ] - 'data' => [] -]; \ No newline at end of file diff --git a/addon/alilife/config/event.php b/addon/alilife/config/event.php deleted file mode 100644 index 82d358b..0000000 --- a/addon/alilife/config/event.php +++ /dev/null @@ -1,44 +0,0 @@ - [], - 'listen' => [ - //展示活动 - 'ShowPromotion' => [ - 'addon\alilife\event\ShowPromotion', - ], - // 订单发货 - 'OrderDelivery' => [ - 'addon\alilife\event\OrderDelivery' - ], - // 订单收货 - 'OrderTakeDelivery' => [ - 'addon\alilife\event\OrderTakeDelivery' - ], - 'AliGatewayNotify' => [//网关通知 - 'addon\alilife\event\AliGoodsStatusNotify' - ], - 'AutoPushOrderDelivery' => [ //验证自动发货 - 'addon\alilife\event\AutoPushOrderDelivery' - ], - 'GoodsEdit' => [ - 'addon\alilife\event\GoodsEdit' - ], - 'AddGoods' => [ - 'addon\alilife\event\AddGoods' - ], - 'editGoodsInfo'=>[//获取编辑信息 - 'addon\alilife\event\editGoodsInfo' - ], - 'AoutSyncGoodsAlipay'=>[//同步支付宝商品 - 'addon\alilife\event\AoutSyncGoodsAlipay' - ], - 'SyncImageGoodsAlipay'=>[ - 'addon\alilife\event\SyncImageGoodsAlipay' - ], - 'AlbumUpload'=>[//相册图形上传事件 - 'addon\alilife\event\AlbumUpload' - ] - ], - 'subscribe' => [], -]; diff --git a/addon/alilife/config/info.php b/addon/alilife/config/info.php deleted file mode 100644 index 1771faa..0000000 --- a/addon/alilife/config/info.php +++ /dev/null @@ -1,21 +0,0 @@ - 'alilife', - 'title' => '支付宝生活号', - 'description' => '支付宝本地生活,生活号,支付宝直播带货', - 'type' => 'tool', //插件类型 system :系统插件(自动安装), business:业务插件 promotion:扩展营销插件 tool:工具插件 - 'status' => 1, - 'author' => '', - 'version' => '1.0.0', - 'version_no' => '520230316001', - 'content' => '', -]; \ No newline at end of file diff --git a/addon/alilife/config/menu_shop.php b/addon/alilife/config/menu_shop.php deleted file mode 100644 index ab51358..0000000 --- a/addon/alilife/config/menu_shop.php +++ /dev/null @@ -1,66 +0,0 @@ - 'SHOP_ALILIFE_ROOT', - 'title' => '生活号', - 'url' => 'alilife://shop/goods/lists', - 'picture' => 'addon/shopcomponent/shop/view/public/img/live_new.png', - 'picture_selected' => 'addon/shopcomponent/shop/view/public/img/live_select.png', - 'parent' => 'SHOP_ALIAPP_ROOT', - 'is_show' => 0, - 'sort' => 1, - 'child_list' => [ - [ - 'name' => 'SHOP_ALILIFE_GOODS', - 'title' => '普通商品', - 'url' => 'alilife://shop/goods/lists', - 'is_show' => 1, - 'sort' => 1, - 'child_list' => [] - ], - [ - 'name' => 'SHOP_LIFEGROUP_GOODS', - 'title' => '本地团购', - 'url' => 'alilife://shop/goods/lifelists', - 'is_show' => 1, - 'sort' => 2, - 'child_list' => [ - [ - 'name' => 'SHOP_LIFEGROUP_ADDGOODS', - 'title' => '添加商品', - 'url' => 'alilife://shop/goods/add', - 'is_show' => 0, - ], - [ - 'name' => 'SHOP_LIFEGROUP_EDITGOODS', - 'title' => '编辑商品', - 'url' => 'alilife://shop/goods/edit', - 'is_show' => 0, - ] - ] - ], - [ - 'name' => 'SHOP_ALILIFE_CATEGORY', - 'title' => '类目管理', - 'url' => 'alilife://shop/category/lists', - 'is_show' => 1, - 'sort' => 3, - 'child_list' => [] - ], - ] - ], - [ - 'title' => '支付宝对账', - 'name' => 'PROMOTION_Alipay', - 'url' => 'alilife://shop/order/miniOrderItembill', - 'parent' => 'ACCOUNT_MANAGE', - 'picture' => 'app/shop/view/public/img/icon_new/member_withdraw_new.png', - 'picture_selected' => 'app/shop/view/public/img/icon_new/member_withdraw_select.png', - 'is_show' => 1, - 'is_control' => 1, - 'sort' => 6 - ] -]; diff --git a/addon/alilife/event/AddGoods.php b/addon/alilife/event/AddGoods.php deleted file mode 100644 index e36cb41..0000000 --- a/addon/alilife/event/AddGoods.php +++ /dev/null @@ -1,17 +0,0 @@ -newAddGoods($data); - } -} \ No newline at end of file diff --git a/addon/alilife/event/AlbumUpload.php b/addon/alilife/event/AlbumUpload.php deleted file mode 100644 index f37d562..0000000 --- a/addon/alilife/event/AlbumUpload.php +++ /dev/null @@ -1,14 +0,0 @@ -UploadImage($data['relate_id']); - } - return error(-1, '任务数据错误'); - } -} \ No newline at end of file diff --git a/addon/alilife/event/AliGoodsStatusNotify.php b/addon/alilife/event/AliGoodsStatusNotify.php deleted file mode 100644 index e4f6a3f..0000000 --- a/addon/alilife/event/AliGoodsStatusNotify.php +++ /dev/null @@ -1,27 +0,0 @@ -StatusNotify($param); - break; - case 'alipay.open.mini.order.changed'://订单通知 - $json = $param['biz_content']; - (new Order())->OrderStatus($json); - break; - } - } - } -} \ No newline at end of file diff --git a/addon/alilife/event/AoutSyncGoodsAlipay.php b/addon/alilife/event/AoutSyncGoodsAlipay.php deleted file mode 100644 index 6479a6a..0000000 --- a/addon/alilife/event/AoutSyncGoodsAlipay.php +++ /dev/null @@ -1,14 +0,0 @@ -AoutSyncGoodsAlipay(); - } -} \ No newline at end of file diff --git a/addon/alilife/event/AutoPushOrderDelivery.php b/addon/alilife/event/AutoPushOrderDelivery.php deleted file mode 100644 index b593bd7..0000000 --- a/addon/alilife/event/AutoPushOrderDelivery.php +++ /dev/null @@ -1,74 +0,0 @@ -getList([ - ['is_video_number', '=', 1], - ['is_sync_order', 'in', [0, 2]], - ['order_status', '=', 3], - ], $field, '', 'o', $join, '', 30); - if ($orderInfo) { - foreach ($orderInfo as $item) { - if (in_array($item['pay_type'], ['alipay', 'zmgopay', 'zmxxpay', 'huabie'])) { - $this->pushOrder($item); - } - } - } - return success(); - } - - /*** - * 推送订单 - * @param $item - * @return void - */ - public function pushOrder($item) - { - $temp = [ - 'TRADE_CREATED' => '订单创建', - 'WAIT_PAY' => '等待支付', - 'PAID' => '支付成功', - 'INIT' => '冻结', - 'PARTIAL_DELIVERED' => '部分发货', - 'DELIVERED' => '全部发货', - 'RECEIVED_CONFIRM' => '确认收货', - 'TIMEOUT_CLOSED' => '超时取消', - 'REFUND_CLOSED' => '全部退款' - ]; - $apiApp = new MinCode($item['site_id']); - $info = $apiApp->miniOrderQuery($item['out_trade_no'], $item['ali_openid']); - if ($info && $info['code'] == 10000 && $info['status'] == 'DELIVERED') { //已发货同步 - model('order')->update(['is_sync_order' => 1, 'sync_msg' => ''], ['order_id' => $item['order_id']]); - } else if ($info['code'] == 10000 && $info['status'] == 'PAID') { - $res = event('OrderDelivery', ['order_id' => $item['order_id']]);//设置发货同步 - if ($res[0]['code'] == 0) { - model('order')->update(['is_sync_order' => 1], ['order_id' => $item['order_id']]); - } else { - model('order')->update(['is_sync_order' => 2, 'sync_msg' => $res[0]['message']], ['order_id' => $item['order_id']]); - } - } else if ($info['code'] != 10000) { - model('order')->update(['is_sync_order' => 3, 'sync_msg' => $info['sub_msg']], ['order_id' => $item['order_id']]); - } else if ($info['code'] == 10000) { - $is_sync_order = 2; - if (in_array($info['status'], ['RECEIVED_CONFIRM', 'REFUND_CLOSED', 'TIMEOUT_CLOSED'])) { - $is_sync_order = 1; - } - model('order')->update(['is_sync_order' => $is_sync_order, 'sync_msg' => $temp[$info['status']]], ['order_id' => $item['order_id']]); - } - } -} \ No newline at end of file diff --git a/addon/alilife/event/GoodsEdit.php b/addon/alilife/event/GoodsEdit.php deleted file mode 100644 index 084f941..0000000 --- a/addon/alilife/event/GoodsEdit.php +++ /dev/null @@ -1,20 +0,0 @@ -GoodsEditupdate($data); - } -} \ No newline at end of file diff --git a/addon/alilife/event/Install.php b/addon/alilife/event/Install.php deleted file mode 100644 index 259ea45..0000000 --- a/addon/alilife/event/Install.php +++ /dev/null @@ -1,26 +0,0 @@ -delivery($param['order_id']); - return $res; - } -} \ No newline at end of file diff --git a/addon/alilife/event/OrderTakeDelivery.php b/addon/alilife/event/OrderTakeDelivery.php deleted file mode 100644 index c6d51f9..0000000 --- a/addon/alilife/event/OrderTakeDelivery.php +++ /dev/null @@ -1,16 +0,0 @@ -takeDelivery($param['order_id']); - return $res; - } - -} \ No newline at end of file diff --git a/addon/alilife/event/ShowPromotion.php b/addon/alilife/event/ShowPromotion.php deleted file mode 100644 index b5924e0..0000000 --- a/addon/alilife/event/ShowPromotion.php +++ /dev/null @@ -1,46 +0,0 @@ - [ - [ - //插件名称 - 'name' => 'alilife', - //店铺端展示分类 shop:营销活动 member:互动营销 - 'show_type' => 'tool', - //展示主题 - 'title' => '支付宝生活号', - //展示介绍 - 'description' => '生活直播,本地生活开启线上带货新模式', - //展示图标 - 'icon' => 'addon/shopcomponent/icon.png', - //跳转链接 - 'url' => 'alilife://shop/goods/lists', - ] - ] - ]; - return $data; - } -} \ No newline at end of file diff --git a/addon/alilife/event/SyncImageGoodsAlipay.php b/addon/alilife/event/SyncImageGoodsAlipay.php deleted file mode 100644 index 3900760..0000000 --- a/addon/alilife/event/SyncImageGoodsAlipay.php +++ /dev/null @@ -1,15 +0,0 @@ -SyncGoodsImage(); - } -} \ No newline at end of file diff --git a/addon/alilife/event/UnInstall.php b/addon/alilife/event/UnInstall.php deleted file mode 100644 index 4f5aaba..0000000 --- a/addon/alilife/event/UnInstall.php +++ /dev/null @@ -1,24 +0,0 @@ -getGoodsInfo($data); - } -} \ No newline at end of file diff --git a/addon/alilife/icon.png b/addon/alilife/icon.png deleted file mode 100644 index dc14f10..0000000 Binary files a/addon/alilife/icon.png and /dev/null differ diff --git a/addon/alilife/model/Category.php b/addon/alilife/model/Category.php deleted file mode 100644 index 3ccbbd4..0000000 --- a/addon/alilife/model/Category.php +++ /dev/null @@ -1,159 +0,0 @@ -pageList($condition, $field, $order, $page, $list_rows, $alias, $join); - return $this->success($data); - } - - /** - * 获取类目通过上级类目ID - * @param $level - * @param int $pid - * @return array - */ - public function getCategoryByParent($site_id,$level,$pid = 0,$cat_type=1,$type='allcategory') - { - $condition=[ - ['site_id','=',$site_id], - ['cat_level','=',$level], - ['api_type','=',$type] - ]; - if($pid){ - $condition[]=['cat_pid','=',$pid]; - } - if($cat_type){ - $condition[]=['cat_type','=',$cat_type]; - } - $list = model('shopalilife_category')->getList($condition, '*', '', '', null, 'cat_id'); - $data = $this->success($list); - Cache::tag('aliCategory')->set("aliCategory_{$level}_{$pid}", $data); - return $data; - } - - public function getCategory($site_id,$type='allcategory',$cat_type=1){ - $condition=[ - ['site_id','=',$site_id], - ['api_type','=',$type], - ['cat_type','=',$cat_type], - ]; - $items = model('shopalilife_category')->getColumn($condition, '*', 'cat_id', '', null, 'cat_id'); - $config=[ - 'id' => 'cat_id', // id名称 - 'pid' => 'cat_pid', // pid名称 - 'title' => 'cat_name', // 标题名称 - 'child' => 'children', // 子元素键名 - 'step' => 3, - ]; - $tree =new Tree($config); - $lists=$tree::toLayer($items); - $temp=[]; - foreach ($lists as $item) { - if ($item['cat_level'] == 1) { - $temp[] = $item; - } - } - return $temp; - } - /** - * 同步商品类目 - */ - public function syncCategory($site_id,$item_type=1,$type='allcategory') - { - if($type=='allcategory'){ - $api='alipay.open.app.item.allcategory.query'; - $key='alipay_open_app_item_allcategory_query_response'; - }else{ - $api='alipay.open.app.localitem.allcategory.query'; - $key='alipay_open_app_localitem_allcategory_query_response'; - } - $res = ( new MinCode($site_id) )->requestApi($api,['item_type'=>$item_type]); - $res=$res[$key]; - if ($res[ 'code' ] != 10000) return $res; - if (!empty($res[ 'cats' ])) { - model('shopalilife_category')->delete([['site_id','=',$site_id],['api_type','=',$type],['cat_type','=',$item_type]]); - $data = []; - foreach ($res[ 'cats' ] as $item) { - foreach ($item['cat_and_parent'] as $value){ - $data[$value['cat_id']]=[ - 'site_id' => $site_id, - 'cat_id' => $value['cat_id'], - 'cat_pid' => $value['f_cat_id']??'', - 'cat_name' => $value['cat_name'], - 'cat_level' => $value['cat_level'], - 'qualification_status' => $value['qualification_status']??'', - 'cat_type' => $item_type, - 'api_type' => $type, - 'create_time' => time(), - ]; - } - } - model('shopalilife_category')->addList(array_values($data)); - return $this->success(1); - }else{ - return $this->error(-1,'未发现有可用分类信息'); - } - } - - - /*** - * 获取模版信息 - * @param $site_id - * @param $cat_id - * @param $type - * @return void - */ - public function getCatTemplate($site_id,$cat_id,$type='allcategory',$item_type=''){ - $data=['category_id'=>$cat_id]; - if($type=='allcategory'){ - $api='alipay.open.app.item.template.query'; - $key='alipay_open_app_item_template_query_response'; - }else{ - $api='alipay.open.app.localitem.template.query'; - $key='alipay_open_app_localitem_template_query_response'; - $data['item_type']=$item_type; - } - $res = ( new MinCode($site_id) )->requestApi($api,$data); - $res=$res[$key]; - return $res; - } - - /** - * 获取分类信息 - * @param $third_cat_id - * @param $site_id - */ - public function getCategoryInfo($third_cat_id, $site_id=0) - { - $info = model('shopalilife_category')->getInfo([['site_id','=',$site_id],[ 'cat_id', '=', $third_cat_id ] ]); - if (empty($info)) return $info; - return $info; - } -} \ No newline at end of file diff --git a/addon/alilife/model/Goods.php b/addon/alilife/model/Goods.php deleted file mode 100644 index 3274001..0000000 --- a/addon/alilife/model/Goods.php +++ /dev/null @@ -1,1739 +0,0 @@ - '未上架', - 5 => '上架中', - 11 => '已下架', - 13 => '违规下架' - ]; - - /** - * 审核状态 - * @var string[] - */ - private $editStatus = [ - 0 => '审核中', - 1 => '编辑中', - 2 => '审核中', - 3 => '审核失败', - 4 => '审核成功', - ]; - private $mime = [ - 'image/jpeg' => '.jpg', - 'image/png' => '.png', - 'image/gif' => '.gif', - 'image/bmp' => '.bmp', - 'image/webp' => '.webp', - ]; - public $image_service; - public $driver; - - public function getBillList($condition = [], $page = 1, $site_id) - { - $aliapp = new MinCode($site_id); - $config = new Config(); - $config_info = $config->getAppConfig($site_id)['data']['value']; - $data = [ - 'mini_app_id' => $config_info['appid'], - 'page_num' => 1, - 'page_size' => 10, - 'order_status' => 'PAID', - ]; - $res = $aliapp->requestApi('alipay.open.mini.order.itembill.batchquery', array_merge($data, $condition))['alipay_open_mini_order_itembill_batchquery_response']; - if ($res['code'] != 10000 || !isset($res['order_list'])) { - $res = [ - 'code' => 1, - 'msg' => '暂无数据', - 'page_num' => 1, - 'page_size' => 10, - 'total' => 0, - 'order_list' => [] - ]; - } else { - if (count($res['order_list'])) { - $out_trade_no = array_column($res['order_list'], 'out_trade_no'); - $pay_out_trade_no = model('pay', 0)->getColumn([['out_trade_no', 'in', $out_trade_no]], '*', 'out_trade_no'); - $order_info = model('order', 0)->getColumn([['out_trade_no', 'in', $out_trade_no]], '*', 'out_trade_no'); - foreach ($res['order_list'] as &$item) { - if (isset($pay_out_trade_no[$item['out_trade_no']]) && isset($order_info[$item['out_trade_no']]) && $order_info[$item['out_trade_no']]['order_status'] != -1) { - $item['out_order_id'] = $order_info[$item['out_trade_no']]['order_id']; - $item['is_sync_bill'] = 1; - $item['out_order_status'] = $order_info[$item['out_trade_no']]['order_status']; - $item['is_sync_delivery'] = $order_info[$item['out_trade_no']]['order_status']; - } else { - $item['is_sync_bill'] = 0; - $item['is_sync_delivery'] = 0; - $item['out_order_id'] = 0; - $item['out_order_status'] = ''; - } - } - } - $res['code'] = 0; - } - return $res; - } - - /** - * 获取商品列表 - * @param array $condition - * @param bool $field - * @param string $order - * @param int $page - * @param int $list_rows - * @param string $alias - * @param array $join - * @return array - */ - public function getGoodsPageList($condition = [], $field = true, $order = '', $page = 1, $list_rows = PAGE_LIST_ROWS, $alias = 'a', $join = []) - { - $field = 'sg.*,g.goods_name,g.goods_image,g.price,g.goods_stock,g.recommend_way'; - $alias = 'sg'; - $join = [ - ['goods g', 'g.goods_id = sg.out_item_id', 'inner'], - ]; - $data = model('shopalilife_goods')->pageList($condition, $field, $order, $page, $list_rows, $alias, $join); - if (!empty($data['list'])) { - foreach ($data['list'] as $k => $item) { - $data['list'][$k]['goods_stock'] = numberFormat($data['list'][$k]['goods_stock']); - $arr_img = explode(',', $item['goods_image']); - $data['list'][$k]['cover_img'] = $arr_img[0] ?? ''; - $data['list'][$k]['create_time'] = $item['create_time'] > 0 ? time_to_date($item['create_time']) : '--'; - $data['list'][$k]['audit_time'] = $item['audit_time'] > 0 ? time_to_date($item['audit_time']) : '--'; - if ($item['reject_reason']) { - $reject_reason = json_decode($item['reject_reason'], true); - if ($reject_reason) { - $data['list'][$k]['reject_reason'] = implode('', array_column($reject_reason, 'remark')); - } - } - } - } - return $this->success($data); - } - - /*** - * 推送普通商品 - * @return void - */ - public function PushPTSyncGoodsInfo($goods_id, $data) - { - $join = [ - ['goods g', 'g.goods_id=a.goods_id', 'right'] - ]; - $where = [ - ['g.goods_id', '=', $goods_id] - ]; - $goods_info = $this->getGoodsInfo($where, 'g.*,a.goods_id as gid,a.spu_data,a.spu_status,a.item_type,a.api_type,a.category_id,a.skus', 'a', $join); - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_id]], 'sku_id,sku_name,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format'); - if (!empty($goods_info['gid'])) { - $skus = json_decode($goods_info['skus'], true); - $spu_data = json_decode($goods_info['spu_data'], true); - $spu_data_names = []; - if ($spu_data) { - $spu_data_names = array_column($spu_data, 'sku_name'); - } - $out_sku_ids = array_column($skus, 'out_sku_id'); - $sku_ids = array_column($sku_list, 'sku_id'); - $sku_names = array_column($sku_list, 'sku_name'); - if (array_diff($out_sku_ids, $sku_ids) || array_diff($sku_names, $spu_data_names)) { - $param['goods_id'] = $goods_id; - $param['site_id'] = $goods_info['site_id']; - $api = 'alipay.open.app.item.modify'; - $response = 'alipay_open_app_item_modify_response'; - return $this->SyncAlipayGoods($param, $api, $response, $data['alipaycategory_id'] ?? ''); - } else { - return $this->syncDtockPrice($goods_id, $goods_info['site_id']); - } - } else { - $api = 'alipay.open.app.item.create'; - $key = 'alipay_open_app_item_create_response'; - $data['site_id'] = $goods_info['site_id']; - $data['goods_id'] = $goods_id; - $data['goods_name'] = $goods_info['goods_name']; - return $this->SyncAlipayGoods($data, $api, $key, $data['alipaycategory_id']); - } - } - - public function PushLocaSyncGoodsInfo($goods_id, $data) - { - - } - - /** - * 同步商品库商品 - */ - public function syncGoods($start = 1, $limit = 20, $site_id, $type = 'allcategory') - { - if ($type == 'allcategory') { - $api = 'alipay.open.app.item.list.query'; - $key = 'alipay_open_app_item_list_query_response'; - } else { - $api = 'alipay.open.app.localitem.allcategory.query'; - $key = 'alipay_open_app_localitem_allcategory_query_response'; - } - $aliapp = new MinCode($site_id); - $res = $aliapp->requestApi($api, ['page_num' => $start, 'page_size' => $limit]); - $sync_res = $res[$key]; - if ($sync_res['code'] != 10000) return $sync_res; - if (!empty($sync_res['items'])) { - foreach ($sync_res['items'] as $goods_item) { - $count = model('shopalilife_goods')->getCount([['out_item_id', '=', $goods_item['out_item_id']], ['site_id', '=', $site_id]]); - $is_sync = model('goods')->getCount([['goods_id', '=', $goods_item['out_item_id']], ['site_id', '=', $site_id]]); - if ($count) { - model('shopalilife_goods')->update( - [ - 'spu_status' => $goods_item['spu_status'], - 'stock_num' => $goods_item['stock_num'], - 'category_id' => $goods_item['category_id'], - 'item_id' => $goods_item['item_id'] - ], - [ - ['out_item_id', '=', $goods_item['out_item_id']] - ] - ); - } else { - $category = (new Category())->getCategoryInfo($goods_item['category_id'], $site_id); - $temp = [ - 'site_id' => $site_id, - 'is_sync' => $is_sync, - 'out_item_id' => $goods_item['out_item_id'], - 'item_id' => $goods_item['item_id'], - 'stock_num' => $goods_item['stock_num'], - 'category_id' => $goods_item['category_id'], - 'api_type' => $type, - 'spu_status' => $goods_item['spu_status'], - 'create_time' => time(), - 'update_time' => time(), - 'cat_name' => $category['cat_name'] - ]; - model('shopalilife_goods')->add($temp); - } - } - $total_page = ceil($sync_res['total'] / $limit); - return $this->success(['page' => $start, 'total_page' => $total_page]); - } else { - return $this->success(['page' => $start, 'total_page' => 1]); - } - } - - /*** - * 支付宝状态更新 - * @param $param - * @return array - */ - public function StatusNotify($param) - { - $biz_content = $param['biz_content'] ?? ''; - if ($biz_content) { - $goods_data = [ - 'spu_status' => $biz_content['spu_status'], - 'is_sync' => 1, - 'reject_reason' => json_encode($biz_content['reasons'] ?? '') ?? '' - ]; - model('shopalilife_goods')->update($goods_data, [['out_item_id', '=', $biz_content['out_item_id']]]); - } - return $this->success(); - } - - /*** - * 同步线上价格 - * @param $goods_id - * @param $site_id - * @param $type - * @return array - */ - public function syncDtockPrice($goods_id, $site_id) - { - $api = 'alipay.open.app.item.direct.modify'; - $key = 'alipay_open_app_item_direct_modify_response'; - $goods_info = model('goods')->getInfo([['goods_id', '=', $goods_id], ['site_id', '=', $site_id]], 'goods_id,goods_name,goods_image,sku_id,goods_content'); - $miniapp = new MinCode($site_id); - // 同步商品所需数据 - $spu_data = [ - 'out_item_id' => $goods_info['goods_id'], - 'skus' => [] - ]; - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_info['goods_id']]], 'sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format'); - if (count($sku_list) > 1) { - foreach ($sku_list as $sku_item) { - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - $sku_item['market_price'] = $sku_item['discount_price'] + $sku_item['discount_price'] * 0.5; - } - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - 'sale_price' => $sku_item['discount_price'] * 100, - 'original_price' => $sku_item['market_price'] * 100, - ]; - array_push($spu_data['skus'], $sku_data); - } - } else { - $sku_item = $sku_list[0]; - $spu_data['sale_price'] = $sku_item['discount_price'] * 100; - $spu_data['original_price'] = $sku_item['market_price'] * 100; - $spu_data['stock_num'] = numberFormat($sku_item['stock']); - $spu_data['sale_status'] = 'AVAILABLE'; - unset($spu_data['skus']); - if ($spu_data['original_price'] <= $spu_data['sale_price']) { - $spu_data['original_price'] = $spu_data['sale_price'] + $spu_data['sale_price'] * 0.5; - } - } - $add_res = $miniapp->requestApi($api, $spu_data)[$key]; - if ($add_res['code'] != 10000) return $this->error('', $add_res['sub_msg']); - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['update_time'] = time(); - model('shopalilife_goods')->update($goods_data, [['out_item_id', '=', $goods_id], ['site_id', '=', $site_id]]); - return $this->success(); - } - - /*** - * 同步本地商品价格 - * @param $goods_id - * @param $site_id - * @param $type - * @return array|void - */ - public function syncLocalitemPrice($goods_id, $site_id) - { - - $api = 'alipay.open.app.localitem.direct.modify'; - $key = 'alipay_open_app_localitem_direct_modify_response'; - $goods_info = model('goods')->getInfo([['goods_id', '=', $goods_id], ['site_id', '=', $site_id]], 'goods_id,goods_name,goods_image,sku_id,goods_content'); - $miniapp = new MinCode($site_id); - // 同步商品所需数据 - $groupboy = new \addon\groupbuy\model\Groupbuy(); - $gwhere = [ - ['g.goods_id', '=', $goods_id] - ]; - $groupboyInfo = $groupboy->getGroupbuyInfo($gwhere)['data']; - $spu_data = [ - 'out_item_id' => $goods_info['goods_id'], - 'sold_time' => [ - 'start_time' => date('Y-m-d H:i:s', $groupboyInfo['start_time']), - 'end_time' => date('Y-m-d H:i:s', $groupboyInfo['end_time']), - ], - 'skus' => [ - [ - 'sale_price' => $groupboyInfo['groupbuy_price'] * 100, - 'original_price' => $groupboyInfo['price'] * 100, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($groupboyInfo['goods_stock']), - ] - ] - ]; - $add_res = $miniapp->requestApi($api, $spu_data)[$key]; - if ($add_res['code'] != 10000) return $this->error('', $add_res['sub_msg']); - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['update_time'] = time(); - model('shopalilife_goods')->update($goods_data, [['out_item_id', '=', $goods_id], ['site_id', '=', $site_id]]); - return $this->success(); - } - - /*** - * 查询商品信息 - * @param $site_id - * @param $item_id - * @param $type - * @return mixed - */ - public function goodsQuery($site_id, $item_id, $type = 'allcategory') - { - $aliapp = new MinCode($site_id); - if ($type == 'allcategory') { - $api = 'alipay.open.app.item.query'; - $key = 'alipay_open_app_item_modify_response'; - } else { - $api = 'alipay.open.app.localitem.modify'; - $key = 'alipay_open_app_localitem_modify_response'; - } - $res = $aliapp->requestApi('alipay.open.app.item.query', ['item_id' => $item_id]); - $query = $res['alipay_open_app_item_query_response']; - return $query; - } - - /*** - * 获取单品信息 - * @param $param - * @return mixed - */ - public function getGoodsInfo($param, $field = '*', $alias = 'a', $join = null, $data = null) - { - $goodsInfo = model('shopalilife_goods')->getInfo($param, $field, $alias, $join); - $goodsInfo['apptype'] = 'aliapp'; - return $goodsInfo; - } - - /** - * 添加商品 - * @param $param - */ - public function addGoods($param, $type = 'allcategory') - { - $goods_list = model('goods')->getList([['goods_id', 'in', explode(',', $param['goods_ids'])], ['site_id', '=', $param['site_id']]], 'goods_id,goods_name,goods_image,sku_id,goods_content'); - if (!empty($goods_list)) { - $category = (new Category())->getCategoryInfo($param['cat_id'], $param['site_id']); - $miniapp = new MinCode($param['site_id']); - if ($type == 'allcategory') { - $api = 'alipay.open.app.item.create'; - $key = 'alipay_open_app_item_create_response'; - } else { - $api = 'alipay.open.app.localitem.create'; - $key = 'alipay_open_app_localitem_create_response'; - } - $miniConfig = $miniapp->getConfig(); - foreach ($goods_list as $goods_item) { - // 需加到库中的商品数据 - $goods_data = [ - 'out_item_id' => $goods_item['goods_id'], - 'category_id' => $param['cat_id'] - ]; - //处理图片 - $goods_image_arr = $this->handleImg($goods_item['goods_image'], 'BIG'); - $image_list = []; - $image_urls = []; - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - foreach ($goods_image_arr as $img_k => $img_y) { - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - $image = $this->image_service->open(img($img_y))->thumb(750, 750); - $file = root_path() . 'runtime/temp/' . $goods_item['goods_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($img_k . $goods_item['goods_name'], $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - $image_urls[] = $res['image_url']; - } - } - } else { - $image_urls[] = 'https://oalipay-dl-django.alicdn.com/rest/1.0/image?fileIds=' . $img_y; - if (count($image_list) < 3) { - $image_list[] = $img_y; - } - } - } - $url = urlencode("pages_market/goods/detail?goods_id={$goods_item[ 'goods_id' ]}"); - // 同步商品所需数据 - $spu_data = [ - 'title' => $goods_item['goods_name'], - 'path' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$url}", - 'head_img' => $image_list[0], - 'image_list' => $image_list, - 'desc_info' => [ - 'desc' => $goods_item['goods_name'] - ], - 'skus' => [] - ]; - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_item['goods_id']]], 'sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format'); - if (count($sku_list) > 1) { - foreach ($sku_list as $keys => $sku_item) { - if ($keys >= 50) { - continue; - } - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - $sku_item['market_price'] = $sku_item['discount_price'] + $sku_item['discount_price'] * 0.5; - } - $sku_image = $this->handleImg($sku_item['sku_image'], 'MID')[0]; - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - //图片处理 - $image = $this->image_service->open(img($this->handleImg($sku_item['sku_image'])[0]))->thumb(400, 400); - $file = root_path() . 'runtime/temp/' . $sku_item['sku_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $sku_res = $miniapp->imageUpload($sku_item['sku_id'], $file, true)['alipay_offline_material_image_upload_response']; - if ($sku_res['code'] == 10000) { - $sku_image = $sku_res['image_id']; - } - } - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'thumb_img' => $sku_image, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - 'sale_price' => $sku_item['discount_price'] * 100, - 'original_price' => $sku_item['market_price'] * 100, - 'item_details_page_model' => 0, - 'sku_attrs' => [], - ]; - if (!empty($sku_item['sku_spec_format'])) { - foreach (json_decode($sku_item['sku_spec_format'], true) as $spec_item) { - array_push($sku_data['sku_attrs'], [ - 'attr_key' => $spec_item['spec_name'], - 'attr_value' => $spec_item['spec_value_name'] - ]); - } - } else { - $sku_data['sku_attrs'] = [ - [ - 'attr_key' => $sku_item['sku_id'], - 'attr_value' => $sku_item['sku_id'] - ] - ]; - } - array_push($spu_data['skus'], $sku_data); - } - } else { - $sku_item = $sku_list[0]; - $spu_data['sale_price'] = $sku_item['discount_price'] * 100; - $spu_data['original_price'] = $sku_item['market_price'] * 100; - $spu_data['stock_num'] = numberFormat($sku_item['stock']); - $spu_data['sale_status'] = 'AVAILABLE'; - $spu_data['item_details_page_model'] = 0; - unset($spu_data['skus']); - if ($spu_data['original_price'] <= $spu_data['sale_price']) { - return $this->error('', '销售价格必须小于划线价'); - } - } - $add_res = $miniapp->requestApi($api, array_merge($goods_data, $spu_data))[$key]; - if ($add_res['code'] != 10000) return $this->error('', $add_res['sub_msg']); - $goods_data['is_sync'] = 1; - $goods_data['api_type'] = $type; - $goods_data['spu_status'] = 'AUDITING'; - $goods_data['goods_id'] = $goods_item['goods_id']; - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['goods_image'] = implode(',', $image_urls); - $goods_data['goods_content'] = $this->getGoodsContent($param['site_id'], $goods_item); - $goods_data['skus'] = json_encode($add_res['skus']); - $goods_data['spu_data'] = json_encode($spu_data); - $goods_data['create_time'] = time(); - $goods_data['site_id'] = $param['site_id']; - $goods_data['cat_name'] = $category['cat_name']; - model('shopalilife_goods')->add($goods_data); - } - return $this->success(); - } else { - return $this->error('', '未获取到要添加的商品'); - } - } - - /**** - * 添加新商品任务 - * @param $param - * @param $type - * @return array|void - */ - public function newAddGoods($param, $type = 'allcategory', $item_type = 1) - { - if (isset($param['alipay_cat_id']) && !$param['alipay_cat_id']) return $this->error(); - $category = (new Category())->getCategoryInfo($param['alipay_cat_id'], $param['site_id']); - if ($category) { - $goods_data['is_sync'] = 0; - $goods_data['out_item_id'] = $param['goods_id']; - $goods_data['goods_id'] = $param['goods_id']; - $goods_data['goods_name'] = $param['goods_name']; - $goods_data['item_id'] = 0; - $goods_data['item_type'] = $item_type; - $goods_data['edit_status'] = 1; - $goods_data['api_type'] = $type; - $goods_data['category_id'] = $param['alipay_cat_id']; - $goods_data['spu_status'] = 'NOTSYNC'; - $goods_data['skus'] = '{}'; - $goods_data['create_time'] = time(); - $goods_data['site_id'] = $param['site_id']; - $goods_data['cat_name'] = $category['cat_name']; - $res = model('shopalilife_goods')->add($goods_data); - return $this->success($res); - } - return $this->error(); - } - - /*** - * 自动同步同步商品支付宝 - * @return void - */ - public function AoutSyncGoodsAlipay() - { - $where = [ - ['l.is_sync', '=', 0] - ]; - $join = [ - ['goods g', 'l.goods_id=g.goods_id', 'inner'] - ]; - $field = 'l.*'; - $goodsList = model('shopalilife_goods')->getList($where, $field, 'create_time desc', 'l', $join, '', 1); - if ($goodsList) { - foreach ($goodsList as $item) { - $item['cat_id'] = $item['category_id']; - if ($item['spu_status'] == 'NOTSYNC' && $item['api_type'] == 'allcategory') { - $api = 'alipay.open.app.item.create'; - $key = 'alipay_open_app_item_create_response'; - $this->SyncAlipayGoods($item, $api, $key); - } else if ($item['edit_status'] == 1 && $item['api_type'] == 'allcategory') { - $this->SyncAlipayGoods($item); - } else if ($item['spu_status'] == 'NOTSYNC' && $item['api_type'] != 'allcategory') { - $this->localitemAddGoods($item, $item['item_type']); - } else if ($item['edit_status'] == 0 && $item['api_type'] != 'allcategory') { - $this->updateGoodslocalitemGoods($item['goods_id'], $item, $item['item_type']); - } else { - echo date('Y-m-d', time()); - } - } - } - return $this->success(); - } - - /*** - * 同步支付宝修改支付宝 - * @param $param - * @param $api - * @param $response - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function SyncAlipayGoods($param, $api = 'alipay.open.app.item.modify', $response = 'alipay_open_app_item_modify_response', $category_id = '') - { - $field = 'sg.*,g.goods_id,g.goods_name,g.goods_image,g.sku_id,g.goods_content'; - $alias = 'sg'; - $join = [ - ['goods g', 'g.goods_id = sg.out_item_id', 'inner'], - ]; - $condition = [ - ['g.goods_id', '=', $param['goods_id']], - ['g.site_id', '=', $param['site_id']], - ]; - $goods_info = model('shopalilife_goods')->getInfo($condition, $field, $alias, $join); - $error = ''; - if (!empty($goods_info)) { - $cat_id = $category_id ?: $goods_info['category_id']; - $category = (new Category())->getCategoryInfo($cat_id, $param['site_id']); - $miniapp = new MinCode($param['site_id']); - //处理图片 - $goods_image_arr = $this->handleImg($goods_info['goods_image'], 'BIG'); - $image_list = []; - $image_urls = []; - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - foreach ($goods_image_arr as $img_k => $img_y) { - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - $image = $this->image_service->open(img($img_y))->thumb(750, 750); - $file = root_path() . 'runtime/temp/' . $goods_info['goods_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($goods_info['goods_id'], $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - } - $image_urls[] = $res['image_url']; - } - } else { - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - } - } - } - $url = urlencode("pages_market/goods/detail?goods_id={$goods_info[ 'goods_id' ]}"); - $miniConfig = $miniapp->getConfig(); - // 同步商品所需数据 - $spu_data = [ - 'out_item_id' => $goods_info['goods_id'], - 'category_id' => $cat_id, - 'title' => $goods_info['goods_name'], - 'path' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$url}", - 'head_img' => $image_list[0], - 'desc_info' => [ - 'desc' => $goods_info['goods_name'] - ], - 'skus' => [] - ]; - $sku_list = Db::name('goods_sku')->where([['goods_id', '=', $goods_info['goods_id']]])->field('sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format')->select(); - if (count($sku_list) > 1) { - foreach ($sku_list as $keys => $sku_item) { - if ($keys > 50) { - $error = 'SKU大于50个部分属性丢失'; - continue; - } - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - $sku_item['market_price'] = $sku_item['discount_price'] + $sku_item['discount_price'] * 0.5; - } - $sku_image = $this->handleImg($sku_item['sku_image'], 'MID')[0]; - //图片处理 - if (strpos($sku_image, 'http://') || strpos($sku_image, 'https://')) { - $image = $this->image_service->open(img($this->handleImg($sku_item['sku_image'])[0]))->thumb(400, 400); - $file = root_path() . 'runtime/temp/' . $sku_item['sku_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $sku_res = $miniapp->imageUpload($sku_item['sku_id'], $file, true)['alipay_offline_material_image_upload_response']; - $sku_image = ""; - if ($sku_res['code'] == 10000) { - $sku_image = $sku_res['image_id']; - } - } - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'thumb_img' => $sku_image, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - 'sale_price' => $sku_item['discount_price'] * 100, - 'original_price' => $sku_item['market_price'] * 100, - 'item_details_page_model' => 0, - 'sku_attrs' => [], - ]; - if (!empty($sku_item['sku_spec_format'])) { - foreach (json_decode($sku_item['sku_spec_format'], true) as $spec_item) { - array_push($sku_data['sku_attrs'], [ - 'attr_key' => $spec_item['spec_name'], - 'attr_value' => $spec_item['spec_value_name'] - ]); - } - } - array_push($spu_data['skus'], $sku_data); - } - } else { - $sku_item = $sku_list[0]; - $spu_data['sale_price'] = $sku_item['discount_price'] * 100; - $spu_data['original_price'] = $sku_item['market_price'] * 100; - $spu_data['stock_num'] = numberFormat($sku_item['stock']); - $spu_data['image_list'] = $image_list; - $spu_data['sale_status'] = 'AVAILABLE'; - $spu_data['item_details_page_model'] = 0; - if ($spu_data['original_price'] <= $spu_data['sale_price']) { - $spu_data['original_price'] = $spu_data['sale_price'] + $spu_data['sale_price'] * 0.5; - } - unset($spu_data['skus']); - } - $add_res = $miniapp->requestApi($api, $spu_data)[$response]; - if ($add_res['code'] != 10000) { - $error = $add_res['sub_msg']; - } else { - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['skus'] = json_encode($add_res['skus']); - $goods_data['spu_status'] = 'AUDITING'; - } - $goods_data['goods_image'] = implode(',', $image_urls); - $goods_data['goods_content'] = $this->getGoodsContent($param['site_id'], $goods_info); - $goods_data['update_time'] = time(); - $goods_data['edit_status'] = 2; - $goods_data['reject_reason'] = $error; - $goods_data['cat_name'] = $category['cat_name']; - $goods_data['spu_data'] = json_encode($spu_data); - model('shopalilife_goods')->update($goods_data, [['out_item_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]]); - if ($error) return $this->error($error); - return $this->success(); - } else { - model('shopalilife_goods')->delete([['out_item_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]]); - $param['alipay_cat_id'] = $category_id; - return $this->newAddGoods($param); - } - } - - - /*** - * 同步商城图片 - * @return void - * @throws \think\db\exception\DbException - */ - public function SyncGoodsImage() - { - $field = 'sg.id,sg.site_id,sg.item_id,sg.api_type,sg.out_item_id,sg.goods_image as image,g.goods_id,g.goods_image,g.goods_content'; - $alias = 'sg'; - $join = [ - ['goods g', 'g.goods_id = sg.out_item_id', 'inner'] - ]; - $condition = [ - ['sg.reject_reason', '<>', 'imgerr'], - ['sg.spu_status', '<>', 'NOTSYNC'], - ['sg.goods_id', '>', 0], - ['sg.goods_image', '=', ''] - ]; - $goods_info = model('shopalilife_goods')->getList($condition, $field, '', $alias, $join, '', 10); - if ($goods_info) { - foreach ($goods_info as $item) { - $goodsInfo = $this->goodsQuery($item['site_id'], $item['item_id'], $item['api_type']); - if ($goodsInfo['code'] == '10000' && isset($goodsInfo['image_list'])) { - $data['goods_image'] = implode(',', $goodsInfo['image_list']); - $data['goods_content'] = $this->getGoodsContent($item['site_id'], $item); - model('shopalilife_goods')->update($data, ['goods_id' => $item['goods_id'], 'site_id' => $item['site_id']]); - } else { - $data['reject_reason'] = 'imgerr'; - } - model('shopalilife_goods')->update($data, ['goods_id' => $item['goods_id'], 'site_id' => $item['site_id']]); - } - return $this->success('成功'); - } - return $this->error('无数据'); - } - - - /*** - * 上传产品图片到支付宝 - * @param $id - * @return array|void - */ - public function UploadImage($id = '') - { - try { - $albumInfo = Db::name('album_pic')->where('pic_id', '=', $id)->field('pic_id,pic_path,site_id,thumb_value')->find(); - if ($albumInfo && !$albumInfo['thumb_value']) { - $config_model = new Config(); - $config_info = $config_model->getAppConfig($albumInfo['site_id'])['data']['value']; - if (isset($config_info['account'])) { - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - $miniapp = new MinCode($albumInfo['site_id']); - $ali_pic_value = []; - $ali_pic_path = ''; - //图片处理 - $image = $this->image_service->open(img($albumInfo['pic_path'])); - $file1 = root_path() . 'runtime/temp/' . md5($albumInfo['pic_path']) . $this->mime[$image->image->mime]; - if (strpos($albumInfo['pic_path'], 'alicdn.com') !== false && (strpos($albumInfo['pic_path'], 'http://') !== false || strpos($albumInfo['pic_path'], 'https://') !== false)) { - $image->save($file1, 100); - $pic_path = $miniapp->imageUpload(md5($albumInfo['pic_path']), $file1, true)['alipay_offline_material_image_upload_response']; - if ($pic_path['code'] == 10000) { - $ali_pic_path = $pic_path['image_url']; - } - } - $image = $this->image_service->open($file1)->thumb(400, 400); - $file = root_path() . 'runtime/temp/' . md5($albumInfo['pic_path']) . '_400' . $this->mime[$image->image->mime]; - $image->save($file, 100); - $img_400 = $miniapp->imageUpload(md5($albumInfo['pic_path']) . '_400', $file, true)['alipay_offline_material_image_upload_response']; - if ($img_400['code'] == 10000) { - $ali_pic_value['MID'] = [ - 'size' => 'BIG', - "width" => 400, - "height" => 400, - 'image_id' => $img_400['image_id'], - 'thumb_name' => $img_400['image_url'], - ]; - } - $image = $this->image_service->open($file1)->thumb(750, 750); - $file = root_path() . 'runtime/temp/' . md5($albumInfo['pic_path']) . '_750' . $this->mime[$image->image->mime]; - $image->save($file, 100); - $img_750 = $miniapp->imageUpload(md5($albumInfo['pic_path']) . '_750', $file, true)['alipay_offline_material_image_upload_response']; - if ($img_750['code'] == 10000) { - $ali_pic_value['BIG'] = [ - 'size' => 'BIG', - "width" => 750, - "height" => 750, - 'image_id' => $img_750['image_id'], - 'thumb_name' => $img_750['image_url'], - ]; - } - $data = []; - if ($ali_pic_path) { - $data['ali_pic_path'] = $ali_pic_path; - } - if ($ali_pic_value) { - $data['thumb_value'] = json_encode($ali_pic_value); - } - if ($data) { - $res = Db::name('album_pic')->where('pic_id', '=', $id)->update($data); - return $this->success($res); - } - } - } - return $this->success(); - } catch (\Exception $e) { - return $this->error($e->getMessage()); - } - } - - /*** - * 添加团购商品 - * @return void - */ - public function localitemAddGoods($param, $item_type = '', $merchant_name = '', $phone_number = '') - { - $goods_ids = $param['goods_ids']; - $goods_list = model('goods')->getList([['goods_id', 'in', $goods_ids], ['site_id', '=', $param['site_id']]], 'goods_id,goods_name,goods_image,sku_id,goods_content,unit'); - //保存本地团购信息获取商品信息 - $groupbuy_data = [ - 'site_id' => $param['site_id'], - 'start_time' => strtotime($param['start_time']), - 'end_time' => strtotime($param['end_time']), - 'rule' => $param['notification'] - ]; - $groupbuy_model = new GroupbuyModel(); - $groupbuy_model->addGroupbuy($groupbuy_data, $param['goods_list'], $goods_ids); - if (!empty($goods_list)) { - $category = (new Category())->getCategoryInfo($param['cat_id'], $param['site_id']); - $miniapp = new MinCode($param['site_id']); - $api = 'alipay.open.app.localitem.create'; - $key = 'alipay_open_app_localitem_create_response'; - $miniConfig = $miniapp->getConfig(); - foreach ($goods_list as $goods_item) { - // 需加到库中的商品数据 - $goods_data = [ - 'out_item_id' => $goods_item['goods_id'], - 'category_id' => $param['cat_id'] - ]; - $groupboy = new \addon\groupbuy\model\Groupbuy(); - $gwhere = [ - ['g.goods_id', '=', $goods_item['goods_id']] - ]; - $groupboyInfo = $groupboy->getGroupbuyInfo($gwhere)['data']; - if (empty($groupboyInfo)) return $this->error('', '团购活动不存在'); - //处理图片 - $goods_image_arr = $this->handleImg($goods_item['goods_image'], 'BIG'); - $image_list = []; - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - $chat = urlencode('pages_tool/chat/room'); - foreach ($goods_image_arr as $img_k => $img_y) { - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - $image = $this->image_service->open(img($img_y))->thumb(750, 750); - $file = root_path() . 'runtime/temp/' . $goods_item['goods_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($img_k . $goods_item['goods_name'], $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - } - } else { - return $this->error('', $res['sub_msg'] . '或图片格式不正确'); - } - } else { - if (count($image_list) < 3) { - $image_list[] = $img_y; - } - } - } - $groupboy_url = urlencode("pages_promotion/groupbuy/detail?groupbuy_id={$groupboyInfo[ 'groupbuy_id']}"); - // 同步商品所需数据 - $spu_data = [ - 'title' => $goods_item['goods_name'], - 'path' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$groupboy_url}", - 'merchant_name' => $merchant_name, - 'head_img' => $image_list[0], - 'image_list' => $image_list, - 'item_type' => $item_type, - 'item_details_page_model' => 0, - 'sold_time' => [ - 'start_time' => $param['start_time'], - 'end_time' => $param['end_time'], - ], - 'customer_service_mobile' => [ - 'phone_type' => isMobileNo($phone_number) ? 1 : 2, - 'phone_number' => $phone_number, - 'customer_link' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$chat}", - ], - 'skus' => [] - ]; - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_item['goods_id']]], 'sku_id,sku_name,discount_price,market_price,stock,sku_spec_format'); - if (count($sku_list) > 50) { - return $this->error('', '规格属性不得超过50个'); - } - $commodity = [ - 'group_name' => '商品组', - 'total_count' => '', - 'option_count' => 1, - 'item_list' => [] - ]; - $unit = $goods_item['unit'] ? $goods_item['unit'] : '人'; - $stock = 0; - if (count($sku_list) > 1) { - foreach ($sku_list as $keys => $sku_item) { - if ($keys >= 50) { - continue; - } - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - return $this->error('', '销售价格必须小于划线价'); - } - $stock += numberFormat($sku_item['stock']); - $sku_spec_format = json_decode($sku_item['sku_spec_format'], true)[0]; - $item_list = [ - 'name' => $sku_spec_format['spec_value_name'], - 'count' => 1, - 'count_unit' => $unit, - 'price' => $sku_item['discount_price'] * 100, - 'unit' => '元', - ]; - array_push($commodity['item_list'], $item_list); - } - } else { - $sku_item = $sku_list[0]; - $commodity['item_list'][] = [ - 'name' => $goods_item['goods_name'], - 'count' => 1, - 'count_unit' => $unit, - 'price' => $groupboyInfo['groupbuy_price'] * 100, - 'unit' => '元', - ]; - $stock = numberFormat($sku_item['stock']); - if ($sku_item['market_price'] <= $groupboyInfo['groupbuy_price']) { - return $this->error('', '销售价格必须小于划线价'); - } - } - $skus = [ - 'sale_price' => $groupboyInfo['groupbuy_price'] * 100, - 'original_price' => $groupboyInfo['price'] * 100, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - ]; - $spu_data['skus'][] = $skus; - $commodity['total_count'] = count($commodity['item_list']); - $commodity['option_count'] = 1; - $commodityArr[] = $commodity; - $use_url = urlencode("pages/member/index"); - $use_path = "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$use_url}"; - $spu_data['attrs'] = [ - [ //库存设置 - 'attr_key' => 'limit_stock_rule', - 'attr_value' => [ - 'limit' => 1, - 'num' => $stock, - 'unit' => $unit, - ], - ], - [ - 'attr_key' => 'original_price_source',//原价配置 - 'attr_value' => 1, - ], - [ - 'attr_key' => 'commodity',//套餐 - 'attr_value' => $commodityArr, - ], - [ - 'attr_key' => 'notification',//套餐 - 'attr_value' => $param['notification'], - ], - [ - 'attr_key' => 'select_all_shop',//蚂蚁门店 - 'attr_value' => 1, - ], - [ - 'attr_key' => 'use_date',//可使用日期 - 'attr_value' => [ - 'use_date_type' => 1, - 'use_start_date' => date('Y-m-d', strtotime($param['start_time'])), - 'use_end_date' => date('Y-m-d', strtotime($param['end_time'])), - ], - ], - [ - 'attr_key' => 'use_limit',//使用时间限制 - 'attr_value' => [ - 'use_time_type' => 1 - ], - ], - [ - 'attr_key' => 'limit_buy_rule',//限购 - 'attr_value' => [ - 'limit' => 0, - 'num' => '' - ] - ], - [ - 'attr_key' => 'refund_rule',//退费规则 - 'attr_value' => [ - 'refund_policy' => [1, 2] - ],//使用时间限制 - ], - [ - 'attr_key' => 'merchant_refund_confirm',//由商家确认退款 - 'attr_value' => 2,//使用时间限制1 商家确认,2无需商家确认 - ], - [ - 'attr_key' => 'usage_type',//使用方式 - 'attr_value' => [ - 'usage_list' => [ - ['use_type' => 1], - [ - 'use_type' => 2, - 'use_path' => $use_path, - ], - ] - ], - ], - [ - 'attr_key' => 'verify_type',//核销方式 - 'attr_value' => ['1', '2'], - ], - [ - 'attr_key' => 'verify_type',//核销方式 - 'attr_value' => ['1', '2'], - ], - [ - 'attr_key' => 'code_source_type',//核销码 1三方核销码 2支付宝核销码 - 'attr_value' => '2', - ], - [ - 'attr_key' => 'settle_type',//结算方式 - 'attr_value' => [ - 'settle_type' => '1' - ] - ], - [ - 'attr_key' => 'preorder_rule',//是否预约 - 'attr_value' => [ - 'need_appointment' => false, - 'appointment_instruction' => '',//预约说明 - ], - ], - [ - 'attr_key' => 'contact_info_type',//顾客预留手机信息 - 'attr_value' => '1', - ], - [ - 'attr_key' => 'order_settle_rule',//结算规则 1默认核销结算 - 'attr_value' => ['order_settle_rule' => 1], - ], -// [ -// 'attr_key' => 'detail_rich_desc',//富文本消息 -// 'attr_value' =>[ -// 'type'=>'1', -// 'content'=>$goods_item['goods_content'], -// ] -// ], - [ - 'attr_key' => 'coupon_usage_rule',//是否可以使用优惠券 1不可使用 2可使用 - 'attr_value' => '1', - ], - [ - 'attr_key' => 'verify_tool',//核销工具 - 'attr_value' => '接口API', - ] - ]; - $add_res = $miniapp->requestApi($api, array_merge($goods_data, $spu_data))[$key]; - // 添加商品到小程序 - if ($add_res['code'] != 10000) return $this->error('', $add_res['sub_msg']); - $goods_data['is_sync'] = 1; - $goods_data['api_type'] = 'localitem'; - $goods_data['spu_status'] = 'AUDITING'; - $goods_data['goods_id'] = $goods_item['goods_id']; - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['skus'] = json_encode($add_res['skus']); - $goods_data['create_time'] = time(); - $goods_data['site_id'] = $param['site_id']; - $goods_data['cat_name'] = $category['cat_name']; - $goods_data['site_name'] = $param['merchant_name']; - $goods_data['phone_number'] = $param['phone_number']; - $goods_data['spu_data'] = json_encode($spu_data); - model('shopalilife_goods')->add($goods_data); - } - return $this->success(); - } else { - return $this->error('', '未获取到要添加的商品'); - } - } - - /*** - * 更新本地生活 - * @param $param - * @return void - */ - public function updateGoodslocalitemGoods($goods_id, $param, $item_type) - { - //保存本地团购信息获取商品信息 - $goods_model = new GoodsModel(); - $goods_info = $goods_model->getGoodsInfo([['goods_id', '=', $goods_id]], 'site_id,goods_name,goods_image,price,unit')['data']; - if (!empty($goods_info)) { - $groupbuy_data = [ - 'goods_id' => $goods_id, - 'goods_name' => $goods_info['goods_name'], - 'goods_image' => $goods_info['goods_image'], - 'goods_price' => $goods_info['price'], - 'groupbuy_price' => $param['groupbuy_price'], - 'buy_num' => $param['buy_num'], - 'start_time' => strtotime($param['start_time']), - 'end_time' => strtotime($param['end_time']), - 'rule' => $param['notification'], - ]; - $groupbuy_id = $param['groupbuy_id']; - $groupbuy_model = new GroupbuyModel(); - $groupbuy_model->editGroupbuy($groupbuy_id, $param['site_id'], $groupbuy_data);//编辑团购 - $category = (new Category())->getCategoryInfo($param['cat_id'], $goods_info['site_id']); - $miniapp = new MinCode($goods_info['site_id']); - $api = 'alipay.open.app.localitem.modify'; - $key = 'alipay_open_app_localitem_modify_response'; - $miniConfig = $miniapp->getConfig(); - // 需加到库中的商品数据 - $goods_data = [ - 'out_item_id' => $goods_id, - 'category_id' => $param['cat_id'] - ]; - //处理图片 - $goods_image_arr = $this->handleImg($goods_info['goods_image'], 'BIG'); - $image_list = []; - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - $chat = urlencode('pages_tool/chat/room'); - foreach ($goods_image_arr as $img_k => $img_y) { - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - $image = $this->image_service->open(img($img_y))->thumb(800, 800); - $file = root_path() . 'runtime/temp/' . $goods_id . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($img_k . $goods_info['goods_name'], $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - } - } - } else { - if (count($image_list) < 3) { - $image_list[] = $img_y; - } - } - } - $groupboy_url = urlencode("pages_promotion/groupbuy/detail?groupbuy_id={$groupbuy_id}"); - // 同步商品所需数据 - $spu_data = [ - 'title' => $goods_info['goods_name'], - 'path' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$groupboy_url}", - 'merchant_name' => $param['merchant_name'], - 'head_img' => $image_list[0], - 'image_list' => $image_list, - 'item_type' => $item_type, - 'item_details_page_model' => 0, - 'sold_time' => [ - 'start_time' => $param['start_time'], - 'end_time' => $param['end_time'], - ], - 'customer_service_mobile' => [ - 'phone_type' => isMobileNo($param['phone_number']) ? 1 : 2, - 'phone_number' => $param['phone_number'], - 'customer_link' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$chat}", - ], - 'skus' => [] - ]; - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_id]], 'sku_id,sku_name,discount_price,market_price,stock,sku_spec_format'); - if (count($sku_list) > 25) { - return $this->error('', '规格属性不得超过25个'); - } - $commodity = [ - 'group_name' => '商品组', - 'total_count' => '', - 'option_count' => 1, - 'item_list' => [] - ]; - $unit = $goods_info['unit'] ? $goods_info['unit'] : '人'; - $stock = 0; - if (count($sku_list) > 1) { - foreach ($sku_list as $keys => $sku_item) { - if ($keys >= 25) { - continue; - } - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - return $this->error('', '销售价格必须小于划线价'); - } - $stock += numberFormat($sku_item['stock']); - $sku_spec_format = json_decode($sku_item['sku_spec_format'], true)[0]; - $item_list = [ - 'name' => $sku_spec_format['spec_value_name'], - 'count' => 1, - 'count_unit' => $unit, - 'price' => $sku_item['discount_price'] * 100, - 'unit' => '元', - ]; - array_push($commodity['item_list'], $item_list); - } - } else { - $sku_item = $sku_list[0]; - $commodity['item_list'][] = [ - 'name' => $goods_info['goods_name'], - 'count' => 1, - 'count_unit' => $unit, - 'price' => $param['groupbuy_price'] * 100, - 'unit' => '元', - ]; - $stock = numberFormat($sku_item['stock']); - if ($sku_item['market_price'] <= $param['groupbuy_price']) { - return $this->error('', '销售价格必须小于划线价'); - } - } - $skus = [ - 'sale_price' => $param['groupbuy_price'] * 100, - 'original_price' => $goods_info['price'] * 100, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - ]; - $spu_data['skus'][] = $skus; - $commodity['total_count'] = count($commodity['item_list']); - $commodity['option_count'] = 1; - $commodityArr[] = $commodity; - $use_url = urlencode("pages/member/index"); - $use_path = "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$use_url}"; - $spu_data['attrs'] = [ - [ //库存设置 - 'attr_key' => 'limit_stock_rule', - 'attr_value' => [ - 'limit' => 1, - 'num' => $stock, - 'unit' => $unit, - ], - ], - [ - 'attr_key' => 'original_price_source',//原价配置 - 'attr_value' => 1, - ], - [ - 'attr_key' => 'commodity',//套餐 - 'attr_value' => $commodityArr, - ], - [ - 'attr_key' => 'notification',//套餐 - 'attr_value' => $param['notification'], - ], - [ - 'attr_key' => 'select_all_shop',//蚂蚁门店 - 'attr_value' => 1, - ], - [ - 'attr_key' => 'use_date',//可使用日期 - 'attr_value' => [ - 'use_date_type' => 1, - 'use_start_date' => date('Y-m-d', strtotime($param['start_time'])), - 'use_end_date' => date('Y-m-d', strtotime($param['end_time'])), - ], - ], - [ - 'attr_key' => 'use_limit',//使用时间限制 - 'attr_value' => [ - 'use_time_type' => 1 - ], - ], - [ - 'attr_key' => 'limit_buy_rule',//限购 - 'attr_value' => [ - 'limit' => 0, - 'num' => '' - ] - ], - [ - 'attr_key' => 'refund_rule',//退费规则 - 'attr_value' => [ - 'refund_policy' => [1, 2] - ],//使用时间限制 - ], - [ - 'attr_key' => 'merchant_refund_confirm',//由商家确认退款 - 'attr_value' => 2,//使用时间限制1 商家确认,2无需商家确认 - ], - [ - 'attr_key' => 'usage_type',//使用方式 - 'attr_value' => [ - 'usage_list' => [ - ['use_type' => 1], - [ - 'use_type' => 2, - 'use_path' => $use_path, - ], - ] - ], - ], - [ - 'attr_key' => 'verify_type',//核销方式 - 'attr_value' => ['1', '2'], - ], - [ - 'attr_key' => 'verify_type',//核销方式 - 'attr_value' => ['1', '2'], - ], - [ - 'attr_key' => 'code_source_type',//核销码 1三方核销码 2支付宝核销码 - 'attr_value' => '2', - ], - [ - 'attr_key' => 'settle_type',//结算方式 - 'attr_value' => [ - 'settle_type' => '1' - ] - ], - [ - 'attr_key' => 'preorder_rule',//是否预约 - 'attr_value' => [ - 'need_appointment' => false, - 'appointment_instruction' => '',//预约说明 - ], - ], - [ - 'attr_key' => 'contact_info_type',//顾客预留手机信息 - 'attr_value' => '1', - ], - [ - 'attr_key' => 'order_settle_rule',//结算规则 1默认核销结算 - 'attr_value' => ['order_settle_rule' => 1], - ], - [ - 'attr_key' => 'coupon_usage_rule',//是否可以使用优惠券 1不可使用 2可使用 - 'attr_value' => '1', - ], - [ - 'attr_key' => 'verify_tool',//核销工具 - 'attr_value' => '接口API', - ] - ]; - $add_res = $miniapp->requestApi($api, array_merge($goods_data, $spu_data))[$key]; - // 添加商品到小程序 - if ($add_res['code'] != 10000) return $this->error('', $add_res['sub_msg']); - $goods_data['is_sync'] = 1; - $goods_data['api_type'] = 'localitem'; - $goods_data['spu_status'] = 'AUDITING'; - $goods_data['goods_id'] = $goods_id; - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['skus'] = json_encode($add_res['skus']); - $goods_data['create_time'] = time(); - $goods_data['site_id'] = $goods_info['site_id']; - $goods_data['cat_name'] = $category['cat_name']; - $goods_data['site_name'] = $param['merchant_name']; - $goods_data['phone_number'] = $param['phone_number']; - $goods_data['spu_data'] = json_encode($spu_data); - model('shopalilife_goods')->update($goods_data, ['goods_id' => $goods_id]); - return $this->success(); - } else { - return $this->error('', '未获取到要添加的商品'); - } - } - - /** - * 更新商品 - * @param $param - * @return array - */ - public function updateGoods($param, $type = 'allcategory') - { - $shopcompoent_goods_info = Db::name('shopalilife_goods')->where([['out_item_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]])->find(); - $goods_info = Db::name('goods')->where([['goods_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]])->field('goods_id,goods_name,goods_image,sku_id,goods_content')->find(); - $error = ''; - if (!empty($shopcompoent_goods_info) && !empty($goods_info)) { - $cat_id = $param['cat_id'] ?? $shopcompoent_goods_info['category_id']; - $category = (new Category())->getCategoryInfo($cat_id, $param['site_id']); - $miniapp = new MinCode($param['site_id']); - //处理图片 - $goods_image_arr = $this->handleImg($goods_info['goods_image'], 'BIG'); - $image_list = []; - $image_urls = []; - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - foreach ($goods_image_arr as $img_k => $img_y) { - if (strpos($img_y, 'http://') !== false || strpos($img_y, 'https://') !== false) { - $image = $this->image_service->open(img($img_y))->thumb(750, 750); - $file = root_path() . 'runtime/temp/' . $goods_info['goods_id'] . '_750' . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($goods_info['goods_id'] . '_750', $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - $image_urls[] = $res['image_url']; - if (count($image_list) < 3) { - $image_list[] = $res['image_id']; - } - } - } else { - $image_list[] = $img_y; - $image_urls[] = 'https://oalipay-dl-django.alicdn.com/rest/1.0/image?fileIds=' . $img_y; - } - } - $url = urlencode("pages_market/goods/detail?goods_id={$goods_info[ 'goods_id' ]}"); - $miniConfig = $miniapp->getConfig(); - // 同步商品所需数据 - $spu_data = [ - 'out_item_id' => $goods_info['goods_id'], - 'category_id' => $cat_id, - 'title' => $goods_info['goods_name'], - 'path' => "alipays://platformapi/startApp?appId={$miniConfig['appid']}&page={$url}", - 'head_img' => $image_list[0], - 'desc_info' => [ - 'desc' => $goods_info['goods_name'] - ], - 'skus' => [] - ]; - $sku_list = Db::name('goods_sku')->where([['goods_id', '=', $goods_info['goods_id']]])->field('sku_id,sku_no,sku_image,discount_price,market_price,stock,sku_spec_format')->select(); - if (count($sku_list) > 1) { - foreach ($sku_list as $keys => $sku_item) { - if ($keys > 25) { - $error = 'SKU大于25个部分属性丢失'; - continue; - } - if ($sku_item['market_price'] <= $sku_item['discount_price']) { - $sku_item['market_price'] = $sku_item['discount_price'] + $sku_item['discount_price'] * 0.5; - } - $sku_image = $this->handleImg($sku_item['sku_image'], 'MID')[0]; - if (strpos($sku_image, 'http://') || strpos($sku_image, 'https://')) { - //图片处理 - $image = $this->image_service->open(img($this->handleImg($sku_item['sku_image'])[0]))->thumb(400, 400); - $file = root_path() . 'runtime/temp/' . $sku_item['sku_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $sku_res = $miniapp->imageUpload($sku_item['sku_id'], $file, true)['alipay_offline_material_image_upload_response']; - $sku_image = ""; - if ($sku_res['code'] == 10000) { - $sku_image = $sku_res['image_id']; - } - } - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'thumb_img' => $sku_image, - 'sale_status' => 'AVAILABLE', - 'stock_num' => numberFormat($sku_item['stock']), - 'sale_price' => $sku_item['discount_price'] * 100, - 'original_price' => $sku_item['market_price'] * 100, - 'item_details_page_model' => 0, - 'sku_attrs' => [], - ]; - if (!empty($sku_item['sku_spec_format'])) { - foreach (json_decode($sku_item['sku_spec_format'], true) as $spec_item) { - array_push($sku_data['sku_attrs'], [ - 'attr_key' => $spec_item['spec_name'], - 'attr_value' => $spec_item['spec_value_name'] - ]); - } - } - array_push($spu_data['skus'], $sku_data); - } - } else { - $sku_item = $sku_list[0]; - $spu_data['sale_price'] = $sku_item['discount_price'] * 100; - $spu_data['original_price'] = $sku_item['market_price'] * 100; - $spu_data['stock_num'] = numberFormat($sku_item['stock']); - $spu_data['image_list'] = $image_list; - $spu_data['sale_status'] = 'AVAILABLE'; - $spu_data['item_details_page_model'] = 0; - if ($spu_data['original_price'] <= $spu_data['sale_price']) { - $spu_data['original_price'] = $spu_data['sale_price'] + $spu_data['sale_price'] * 0.5; - } - unset($spu_data['skus']); - } - $add_res = $miniapp->requestApi('alipay.open.app.item.modify', $spu_data)['alipay_open_app_item_modify_response']; - if ($add_res['code'] != 10000) { - $error = $add_res['sub_msg']; - } else { - $goods_data['item_id'] = $add_res['item_id']; - $goods_data['skus'] = json_encode($add_res['skus']); - $goods_data['spu_status'] = 'AUDITING'; - } - $goods_data['goods_image'] = implode(',', $image_urls); - $goods_data['goods_content'] = $this->getGoodsContent($param['site_id'], $goods_info); - $goods_data['update_time'] = time(); - $goods_data['edit_status'] = 2; - $goods_data['reject_reason'] = $error; - $goods_data['cat_name'] = $category['cat_name']; - $goods_data['spu_data'] = json_encode($spu_data); - model('shopalilife_goods')->update($goods_data, [['out_item_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]]); - if ($error) return $this->error($error); - return $this->success(); - } else { - return $this->error('', '未获取到要更新的商品'); - } - } - - /*** - * 替换支付宝图片富文本 - * @param $site_id - * @param $goods_info - * @return string|string[] - * @throws \think\db\exception\DbException - */ - public function getGoodsContent($site_id, $goods_info) - { - $pattern = '/src=\"(.+?)\".*?/'; - $content = $goods_info['goods_content']; - preg_match_all($pattern, $content, $match); - if ($match) { - //处理图片 - $newArr = []; - $images = $match[1]; - $album_pic = Db::name('album_pic')->where('pic_path', 'in', $images)->column('pic_id,pic_path,ali_pic_path', 'pic_path'); - $this->driver = config('upload')['driver'] ?? 'gd'; - $this->image_service = new ImageService($this->driver); - $miniapp = new MinCode($site_id); - foreach ($images as $img_path) { - if (strpos($img_path, 'alicdn.com') || (!isset($album_pic[$img_path]) && strpos($img_path, 'https://') || strpos($img_path, 'http://'))) { - $newArr[] = $img_path; - continue; - } - if (isset($album_pic[$img_path]) && $album_pic[$img_path]['ali_pic_path']) { - $newArr[] = $album_pic[$img_path]['ali_pic_path']; - } else { - $image = $this->image_service->open(img($img_path)); - $file = root_path() . 'runtime/temp/' . $goods_info['goods_id'] . $this->mime[$image->image->mime]; - $image->save($file, 100); - $image = $miniapp->imageUpload($img_path, $file, true); - $res = $image['alipay_offline_material_image_upload_response']; - if ($res['code'] == 10000) { - $newArr[] = $res['image_url']; - Db::name('album_pic')->where('pic_path', '=', $img_path)->update(['ali_pic_path' => $res['image_url']]); - } else { - $newArr[] = $img_path; - } - } - } - return str_replace($images, $newArr, $content); - } - return ''; - } - - /*** - * 编辑商品信息 - * @param $param - * @return void - */ - public function GoodsEditupdate($param) - { - $where = [ - 'site_id' => $param['site_id'], - 'goods_id' => $param['goods_id'], - ]; - $param['cat_id'] = $param['alipay_cat_id']; - $goodsInfo = model('shopalilife_goods')->getInfo($where); - if ($goodsInfo) { - $sku_info = json_decode($goodsInfo['skus'], true); - $out_sku_ids = array_column($sku_info, 'out_sku_id'); - $sku_list = model('goods_sku')->getColumn([['goods_id', '=', $param['goods_id']]], 'sku_id'); - $result = array_udiff($sku_list, $out_sku_ids, function ($a, $b) { - return $a == $b ? 0 : 1; //查询是否有更新SKU - }); - if (empty($result) && $goodsInfo['category_id'] == $param['alipay_cat_id']) { - $this->syncDtockPrice($param['goods_id'], $param['site_id']); - } else { - model('shopalilife_goods')->update(['edit_status' => 1, 'is_sync' => 0, 'reject_reason' => ''], [['out_item_id', '=', $param['goods_id']], ['site_id', '=', $param['site_id']]]); - } - } else { - $this->newAddGoods($param); - } - return $this->success(); - } - - /** - * 处理分割图片 - * @param $images - * @return false|string[] - */ - private function handleImg($images, $size = '') - { - $img_arr = explode(',', $images); - if ($size) { - $thumb_value = model('album_pic')->getColumn(['pic_path' => $img_arr], 'thumb_value', 'pic_path'); - $img_arr = array_map(function ($v) use ($thumb_value, $size) { - if (array_key_exists($v, $thumb_value)) { - $value = json_decode($thumb_value[$v], true); - if (array_key_exists($size, $value)) { - $img_path = $value[$size]; - $thumb_name = $img_path['thumb_name']; - parse_str($thumb_name, $srt); - $v = array_values($srt); - if ($v) { - return $v[0]; - } else { - return img($v); - } - } - } - return img($v); - }, $img_arr); - } else { - $img_arr = array_map('img', $img_arr); - } - return $img_arr; - } - - /** - * 删除商品 - * @param $id - * @param $site_id - */ - public function deleteGoods($goods_ids, $site_id) - { - if (!empty($goods_ids)) { - $array_goodsIds = explode(',', $goods_ids); - } - $res = (new MinCode($site_id))->requestApi('alipay.open.app.item.delete', ['out_item_id_list' => $array_goodsIds]); - model('shopalilife_goods')->delete([['site_id', '=', $site_id], ['out_item_id', 'in', $goods_ids]]); - return $this->success($res); - } - - /** - * 商品上架 - * @param $goods_ids - * @param $site_id - * @return array|mixed - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function goodsListing($goods_ids, $site_id) - { - if (!empty($goods_ids)) { - $array_goodsIds = explode(',', $goods_ids); - } - foreach ($array_goodsIds as $k => $goods_id) { - $api_type = model('shopalilife_goods')->getValue([['out_item_id', '=', $goods_id], ['site_id', '=', $site_id]], 'api_type'); - if ($api_type == 'allcategory') { - $api = 'alipay.open.app.item.direct.modify'; - } else { - $api = 'alipay.open.app.localitem.direct.modify'; - } - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_id]], 'sku_id'); - $spu_data = [ - 'out_item_id' => $goods_id, - 'skus' => [] - ]; - if (count($sku_list) > 1) { - foreach ($sku_list as $sku_item) { - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'sale_status' => 'AVAILABLE', - ]; - array_push($spu_data['skus'], $sku_data); - } - } else { - $spu_data['sale_status'] = 'AVAILABLE'; - } - $res[$k] = (new MinCode($site_id))->requestApi($api, $spu_data); - if ($res[$k]['code'] != 0) return $res[$k]; - } - model('shopcompoent_goods')->update(['spu_status' => 'DELISTING'], [['site_id', '=', $site_id], ['out_item_id', 'in', $goods_ids]]); - return $this->success(); - } - - /** - * 商品下架 - * @param $goods_ids - * @param $site_id - * @return array|mixed - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function goodsDelisting($goods_ids, $site_id) - { - if (!empty($goods_ids)) { - $array_goodsIds = explode(',', $goods_ids); - } - foreach ($array_goodsIds as $k => $goods_id) { - $api_type = model('shopalilife_goods')->getValue([['out_item_id', '=', $goods_id], ['site_id', '=', $site_id]], 'api_type'); - if ($api_type == 'allcategory') { - $api = 'alipay.open.app.item.direct.modify'; - } else { - $api = 'alipay.open.app.localitem.direct.modify'; - } - $sku_list = model('goods_sku')->getList([['goods_id', '=', $goods_id]], 'sku_id'); - $spu_data = [ - 'out_item_id' => $goods_id, - 'skus' => [] - ]; - if (count($sku_list) > 1) { - foreach ($sku_list as $sku_item) { - $sku_data = [ - 'out_sku_id' => $sku_item['sku_id'], - 'sale_status' => 'DELISTING', - ]; - array_push($spu_data['skus'], $sku_data); - } - } else { - $spu_data['sale_status'] = 'DELISTING'; - } - $res[$k] = (new MinCode($site_id))->requestApi($api, $spu_data); - if ($res[$k]['code'] != 0) return $res[$k]; - } - model('shopcompoent_goods')->update(['spu_status' => 'DELISTING'], [['site_id', '=', $site_id], ['out_item_id', 'in', $goods_ids]]); - return $this->success(); - } -} \ No newline at end of file diff --git a/addon/alilife/model/Order.php b/addon/alilife/model/Order.php deleted file mode 100644 index 4c9cc72..0000000 --- a/addon/alilife/model/Order.php +++ /dev/null @@ -1,481 +0,0 @@ - $trade_no - ]; - $info = $apiApp->requestApi('alipay.trade.query', $data)['alipay_trade_query_response']; - $buyer_user_id = $info['buyer_user_id']; - $datas = [ - 'user_id' => $buyer_user_id, - 'order_id' => $order_id, - ]; - if ($info['code'] == 10000) { - $order_mini_query = $apiApp->requestApi('alipay.open.mini.order.query', $datas)['alipay_open_mini_order_query_response']; - if ($order_mini_query['code'] == 10000) { - $order_detail = $order_mini_query['order_detail']['item_infos']; - $pay_info = $order_mini_query['order_detail']['pay_info']; - foreach ($order_detail as $key => $value) { - $condition = [ - 'm.site_id' => $site_id, - 'm.ali_openid' => $buyer_user_id, - 'og.sku_id' => $value['out_sku_id'], - 'o.order_status' => -1, - ]; - $field = 'm.ali_openid,m.member_id,og.*'; - $alias = 'og'; - $join = [ - [ - 'member m', 'm.member_id=og.member_id', 'left' - ], - [ - 'order o', 'og.order_id=o.order_id', 'left' - ] - ]; - $order_info = model('order_goods')->getInfo($condition, $field, $alias, $join); - if ($order_info) { - if (in_array($order_mini_query['status'], ['PAID'])) { - $updata = [ - 'order_status' => 1, - 'pay_status' => 1, - 'is_enable_refund' => 1, - 'out_trade_no' => $info['out_trade_no'], - 'is_video_number' => 1, - 'pay_type' => 'alipay', - 'pay_type_name' => '支付宝支付', - 'pay_money' => $info['buyer_pay_amount'], - 'order_status_name' => '待发货', - 'order_status_action' => '{"status":1,"name":"待发货","is_allow_refund":0,"icon":"public\/resource\/order\/order-icon-send.png","action":[{"action":"orderDelivery","title":"发货","color":""},{"action":"orderAddressUpdate","title":"修改地址","color":""}],"member_action":[],"color":""}', - ]; - model('order')->update($updata, ['order_id' => $order_info['order_id']]); - $data = array( - 'site_id' => $site_id, - 'out_trade_no' => $info['out_trade_no'], - 'pay_type' => 'alipay', - 'trade_no' => $trade_no, - 'pay_body' => $order_info['sku_name'], - 'pay_detail' => $order_info['sku_name'], - 'pay_money' => $info['buyer_pay_amount'], - 'pay_no' => '', - 'event' => 'OrderPayNotify', - 'return_url' => '', - 'pay_status' => 2, - 'create_time' => strtotime($info['send_pay_date']), - 'pay_time' => strtotime($pay_info['pay_time']), - ); - if (!model('pay')->getValue(['out_trade_no' => $info['out_trade_no']], 'id')) { - model('pay')->add($data); - } else { - unset($data['out_trade_no']); - model('pay')->update($data, ['out_trade_no' => $info['out_trade_no']]); - } - } else { - var_dump(555); - } - } else { - $res = $this->createOrder($site_id, $order_detail, $pay_info, $info, $order_mini_query); - return $res; - } - } - } - } - return $this->success('成功'); - } - - /**** - * 同步快递信息 - * @param $order_id - * @param $site_id - * @param $trade_no - * @return void - */ - public function syncDelivery($order_id,$order_status='') - { - $res = $this->delivery($order_id, 1); - if ($res['code'] == 0 && $order_status==10) { - $this->takeDelivery($order_id, 1); - } - return $res; - } - - /*** - * 直接退款 - * @param $trade_no - * @param $order_id - * @param $site_id - * @return void - */ - public function refund($trade_no, $order_id, $site_id) - { - $apiApp = new MinCode($site_id); - $data = [ - 'trade_no' => $trade_no - ]; - $info = $apiApp->requestApi('alipay.trade.query', $data)['alipay_trade_query_response']; - $buyer_user_id = $info['buyer_user_id']; - $datas = [ - 'user_id' => $buyer_user_id, - 'order_id' => $order_id, - ]; - if ($info['code'] == 10000) { - $order_mini_query = $apiApp->requestApi('alipay.open.mini.order.query', $datas)['alipay_open_mini_order_query_response']; - $pay_model = new PayModel($site_id); - $order_detail = $order_mini_query['order_detail']['item_infos'][0]; - $pay_info = $order_mini_query['order_detail']['pay_info']; - $data = [ - 'pay_info' => [ - 'trade_no' => $info['trade_no'], - 'pay_type' => 'alipay', - ], - 'refund_no' => $info['trade_no'], - 'trade_no' => $info['trade_no'], - 'refund_fee' => $info['buyer_pay_amount'], - 'goods_id' => $order_detail['out_item_id'], - 'sku_id' => $order_detail['out_sku_id'], - 'is_video_number' => 1, - ]; - $rse = $pay_model->refund($data); - return $rse; - } - } - - /*** - * 直接创建订单 - * @param $site_id - * @param $order_detail - * @param $pay_info - * @param $info - * @param $order_mini_query - * @return array - */ - public function createOrder($site_id, $order_detail, $pay_info, $info, $order_mini_query) - { - $member_info = model('member')->getInfo(['ali_openid' => $info['buyer_user_id']]); - if (!$member_info) return error(-1, '地址信息不全'); - $member_address = new MemberAddress(); - $type = 1; - $address = $member_address->getMemberAddressInfo([['member_id', '=', $member_info['member_id']], ['is_default', '=', 1], ['type', '=', $type]]); - if ($address) { - $addressInfo = $address['data']; - $out_trade_no = $info['out_trade_no']; - $order_item = model('goods_sku')->getInfo(['sku_id' => $order_detail[0]['out_sku_id']]); - model('order')->startTrans(); - try { - $data_order = [ - 'order_no' => $out_trade_no, - 'site_id' => $site_id, - 'site_name' => '', - 'order_from' => 'alipay', - 'order_from_name' => '支付宝小程序', - 'order_type' => 1, - 'order_status' => 1, - 'pay_status' => 1, - 'is_video_number' => 1, - 'order_type_name' => '普通订单', - 'order_status_name' => '待发货', - 'order_status_action' => '{"status":1,"name":"待发货","is_allow_refund":0,"icon":"public\/resource\/order\/order-icon-send.png","action":[{"action":"orderDelivery","title":"发货","color":""},{"action":"orderAddressUpdate","title":"修改地址","color":""}],"member_action":[],"color":""}', - 'out_trade_no' => $out_trade_no, - 'member_id' => $member_info['member_id'], - 'name' => $addressInfo['name'] ?? '', - 'mobile' => $addressInfo['mobile'] ?? '', - 'telephone' => $addressInfo['telephone'] ?? '', - 'province_id' => $addressInfo['province_id'] ?? '', - 'city_id' => $addressInfo['city_id'] ?? '', - 'district_id' => $addressInfo['district_id'] ?? '', - 'community_id' => $addressInfo['community_id'] ?? '', - 'address' => $addressInfo['address'] ?? '', - 'full_address' => $addressInfo['full_address'] ?? '', - 'longitude' => $addressInfo['longitude'] ?? '', - 'latitude' => $addressInfo['latitude'] ?? '', - 'buyer_ip' => request()->ip(), - 'goods_money' => $info['buyer_pay_amount'], - 'delivery_money' => 0, - 'coupon_id' => 0, - 'coupon_money' => 0, - 'adjust_money' => 0, - 'invoice_money' => 0, - 'promotion_money' => 0, - 'order_money' => $info['buyer_pay_amount'], - 'balance_money' => 0, - 'point_money' => 0, - 'pay_money' => $info['buyer_pay_amount'], - 'create_time' => time(), - 'is_enable_refund' => 0, - 'order_name' => $order_item['sku_name'], - 'goods_num' => $order_detail[0]['item_cnt'], - 'delivery_type' => 'express', - 'delivery_type_name' => '快递配送', - 'delivery_store_id' => $order_item['delivery_store_id'] ?? 0, - 'delivery_store_name' => $order_item['delivery_store_name'] ?? '', - 'delivery_store_info' => $order_item['delivery_store_info'] ?? '', - 'buyer_message' => '', - 'invoice_delivery_money' => $order_item['invoice_delivery_money'] ?? 0, - 'taxpayer_number' => $order_item['taxpayer_number'] ?? '', - 'invoice_rate' => $order_item['invoice_rate'] ?? 0, - 'invoice_content' => $order_item['invoice_content'] ?? '', - 'invoice_full_address' => $order_item['invoice_full_address'] ?? '', - 'is_invoice' => $order_item['is_invoice'] ?? 0, - 'invoice_type' => $order_item['invoice_type'] ?? 0, - 'invoice_title' => $order_item['invoice_title'] ?? '', - 'is_tax_invoice' => $order_item['is_tax_invoice'] ?? '', - 'invoice_email' => $order_item['invoice_email'] ?? '', - 'invoice_title_type' => $order_item['invoice_title_type'] ?? 0, - 'buyer_ask_delivery_time' => $order_item['buyer_ask_delivery_time'] ?? '',//定时达 - 'member_card_money' => 0, - 'store_id' => $order_item['store_id'] ?? '' - ]; - $order_id = model('order')->add($data_order); - $data_order_goods = array( - 'order_id' => $order_id, - 'site_id' => $order_item['site_id'], - 'order_no' => $out_trade_no, - 'member_id' => $member_info['member_id'], - 'sku_id' => $order_item['sku_id'], - 'sku_name' => $order_item['sku_name'], - 'sku_image' => $order_item['sku_image'], - 'sku_no' => $order_item['sku_no'], - 'is_virtual' => $order_item['is_virtual'], - 'goods_class' => $order_item['goods_class'], - 'goods_class_name' => $order_item['goods_class_name'], - 'price' => $order_item['price'], - 'cost_price' => $order_item['cost_price'], - 'num' => $data_order['goods_num'], - 'goods_money' => $data_order['goods_money'], - 'cost_money' => $order_item['cost_price'] * $data_order['goods_num'], - 'goods_id' => $order_item['goods_id'], - 'delivery_status' => 0, - 'delivery_status_name' => '未发货', - 'real_goods_money' => 0, - 'coupon_money' => 0, - 'promotion_money' => 0, - 'goods_name' => $order_item['goods_name'], - 'sku_spec_format' => $order_item['sku_spec_format'], - 'use_point' => $order_item['use_point'] ?? 0, - 'point_money' => $order_item['point_money'] ?? 0.00, - 'create_time' => time(), - 'store_id' => '', - 'card_item_id' => 0, - 'card_promotion_money' => 0.00 - ); - $data = array( - 'site_id' => $site_id, - 'out_trade_no' => $info['out_trade_no'], - 'pay_type' => 'alipay', - 'trade_no' => $info['trade_no'], - 'pay_body' => $data_order_goods['sku_name'], - 'pay_detail' => $data_order_goods['sku_name'], - 'pay_money' => $info['buyer_pay_amount'], - 'pay_no' => '', - 'event' => 'OrderPayNotify', - 'return_url' => '', - 'pay_status' => 2, - 'create_time' => strtotime($info['send_pay_date']), - 'pay_time' => strtotime($pay_info['pay_time']), - ); - if (!model('pay')->getValue(['out_trade_no' => $info['out_trade_no']], 'id')) { - model('pay')->add($data); - } else { - unset($data['out_trade_no']); - model('pay')->update($data, ['out_trade_no' => $info['out_trade_no']]); - } - model('order_goods')->add($data_order_goods); - model('order')->commit(); - return $this->success('成功'); - } catch (\Exception $e) { - model('order')->rollback(); - return error(-1, $e); - } - } else { - return error(-1, '地址信息不全'); - } - } - - /*** - * 发货同步到支付宝 - * @param $order_id - * @param $is_video_number - * @return array - * @throws \GuzzleHttp\Exception\GuzzleException - */ - public function delivery($order_id,$is_video_number=0) - { - try { - $order = model('order')->getInfo([['order_id', '=', $order_id]], 'site_id,order_no,out_trade_no,is_video_number,pay_type,member_id,order_type,delivery_time'); - if ($is_video_number || ($order['is_video_number'] && in_array($order["pay_type"],['alipay','alipay_stages','zmxxpay','huabie','zmautopay','zmgopay']))) { - $member = model('member')->getInfo([['member_id', '=', $order['member_id']]], 'ali_openid'); - $apiApp = new MinCode($order['site_id']); - $data = [ - 'out_order_id' => $order['out_trade_no'], - 'finish_all_delivery' => 1, - 'ship_done_time' => date('Y-m-d H:i:s', $order['delivery_time']), - 'delivery_list' => [] - ]; - if (is_numeric($member['ali_openid'])) { - $data['user_id'] = $member['ali_openid']; - } else { - $data['open_id'] = $member['ali_openid']; - } - if ($order['order_type'] == 1) { - $package_list = model('express_delivery_package')->getList([['order_id', '=', $order_id]], 'delivery_type,express_company_name,delivery_no,order_goods_id_array'); - if (!empty($package_list)) { - $company_list = $apiApp->getCompanyList(); - foreach ($package_list as $item) { - $delivery_id = 'OTHERS'; - $index = array_search($item['express_company_name'], array_column($company_list, 'delivery_name')); - if ($index !== false && isset($company_list[$index])) { - $delivery_id = $company_list[$index]['delivery_id']; - } - $order_goods_model = model('order_goods')->getList([['order_goods_id', "in", $item['order_goods_id_array']]], "goods_id,sku_id,num"); - if ($item['delivery_type'] == 0) { - $item['delivery_no'] = date('YmdHis'); - } - $temp = [ - 'delivery_id' => $delivery_id, - 'waybill_id' => $item['delivery_no'], - 'item_info_list' => [] - ]; - foreach ($order_goods_model as $order_iem) { - $temp['item_info_list'][] = [ - 'out_item_id' => $order_iem['goods_id'], //提报服务库外部商品ID - 'out_sku_id' => $order_iem['sku_id'],//商家SKU - 'item_cnt' => (int)$order_iem['num'] //商品数量 - ]; - } - array_push($data['delivery_list'], $temp); - } - } else { - unset($data['delivery_list']); - } - } - $res = $apiApp->sendDelivery($data); - if ($res['code'] == 10000) { - return $this->success(); - } else if (isset($res['sub_code']) && !in_array($res['sub_code'], ['STATUS_INVALID', 'SEND_ORDER_IS_REPEAT', 'ORDER_ID_NOT_EXIST', 'OUT_ORDER_ID_INVALIDATE'])) { - model('order')->update(['is_sync_order' => 2, 'sync_msg' => $res['sub_msg']], [['order_id', '=', $order_id]]); - return $this->error('', $res['sub_msg']); - } else { //标记订单已同步 - model('order')->update(['is_sync_order' => 2, 'sync_msg' => $res['sub_msg']], [['order_id', '=', $order_id]]); - return $this->success(); - } - return $res; - } - } catch (\Exception $e) { - - } - return $this->success(); - } - - /** - * 订单收货 - * @param $order_id - * @return array - */ - public function takeDelivery($order_id,$is_video_number=0) - { - $order = model('order')->getInfo([['order_id', '=', $order_id]], 'site_id,order_no,out_trade_no,is_video_number,pay_type,member_id,order_type'); - if ($is_video_number || ($order['is_video_number'] && in_array($order["pay_type"],['alipay','alipay_stages','zmxxpay','huabie','zmautopay','zmgopay']))) { - $member = model('member')->getInfo([['member_id', '=', $order['member_id']]], 'ali_openid'); - $apiApp = new MinCode($order['site_id']); - $res = $apiApp->recieveDelivery(['out_order_id' => $order['out_trade_no'], 'user_id' => $member['ali_openid']]); - if ($res['code'] != 10000) { - return $this->error('', $res['sub_msg']); - } - } - return $this->success(); - } - /*** - * 订单状态标记 - * @param $json - * @return void - */ - public function OrderStatus($json) - { - switch ($json['status']) { - case 'RECEIVED_CONFIRM': //确认收货 - $where = [['out_trade_no', '=', $json['out_order_id']]]; - $field = 'o.order_id,m.nickname,m.member_id'; - $join = [ - ['member m', 'o.member_id=m.member_id', 'inner'], - ]; - $orderInfo = model('order')->getInfo($where, $field, 'o', $join); - if ($orderInfo) { - $log_data = [ - 'uid' => $orderInfo['member_id'], - 'nick_name' => $orderInfo['nickname'], - 'action_way' => 2 - ]; - $order_model = new OrderCommonModel(); - $order_model->orderCommonTakeDelivery($orderInfo['order_id'], $log_data); - } - break; - case 'REFUND_CLOSED': //退款 - $where = [['out_trade_no', '=', $json['out_order_id']]]; - $field = 'g.order_goods_id,m.nickname,m.member_id,o.order_id'; - $join = [ - ['order_goods g', 'o.order_id=g.order_id', 'inner'], - ['member m', 'o.member_id=m.member_id', 'inner'], - ]; - $orderInfo = model('order')->getList($where, $field, '', 'o', $join); - $order_refund_model = new OrderRefundModel(); - if ($orderInfo) { - foreach ($orderInfo as $item) { - $buyer_name = empty($item['nickname']) ? '' : '【' . $item['nickname'] . '】'; - $log_data = [ - 'uid' => $item['member_id'], - 'nick_name' => $item['nickname'], - 'action' => '买家' . $buyer_name . '发起了退款申请', - 'action_way' => 1 - ]; - $data = array( - "order_goods_id" => $item['order_goods_id'], - "refund_type" => 1, - "refund_reason" => '会员平台申请退款', - "refund_remark" => '支付宝平台直接申请退款' - ); - $order_refund_model->orderRefundApply($data, $item, $log_data); - } - model('dividemoney_bill')->update(['states' => 5, 'refuse' => '订单已退款'], [['order_id', 'in', array_column($orderInfo, 'order_id')]]);//关闭分账 - } - break; - case 'PAID': - model('order')->update(['is_video_number' => 1], [['out_trade_no', '=', $json['out_order_id']]]); - break; - case 'CANCEL_CLOSED'://交易取消 - case 'TIMEOUT_CLOSED': //超时关闭订单 - $order = new OrderCommon(); - $where = [['out_trade_no', '=', $json['out_order_id']]]; - $order_info_result = $order->getOrderInfo($where, "order_id,order_status"); - if (!empty($order_info_result) && $order_info_result["data"]["order_status"] == 0) { - $order->orderClose($order_info_result['data']["order_id"], [], '长时间未支付,订单自动关闭');//订单自动关闭 - } - break; - } - return success(); - } -} \ No newline at end of file diff --git a/addon/alilife/shop/controller/Category.php b/addon/alilife/shop/controller/Category.php deleted file mode 100644 index c5ce650..0000000 --- a/addon/alilife/shop/controller/Category.php +++ /dev/null @@ -1,111 +0,0 @@ -isAjax()) { - $category = new CategoryModel(); - $page = input('page', 1); - $keywords = empty(input('keywords')) ? '' : input('keywords'); - $page_size = input('page_size', PAGE_LIST_ROWS); - if (!empty($keywords)) { - $condition [] = ['cat_name', 'like', '%' . $keywords . '%']; - } - if (!empty($third_cat_id)) { - $condition [] = ['cat_id', '=', $third_cat_id]; - } - $condition [] = ['site_id', '=', $this->site_id]; - $data = $category->getcategoryPageList($condition, '*', '', $page, $page_size); - return $data; - } else { - $this->assign('third_cat_id', $third_cat_id); - $this->forthMenu(); - return $this->fetch("category/index"); - } - } - - public function template() - { - if (request()->isAjax()) { - $category = new CategoryModel(); - $cat_id = input('cat_id', ''); - $res = $category->getCatTemplate($this->site_id, $cat_id); - return $res; - } - } - - /** - * 同步商品类目 - * @return array - */ - public function sync() - { - if (request()->isAjax()) { - $category = new CategoryModel(); - $type = input('type', 'allcategory'); - $item_type = input('item_type', 1); - $res = $category->syncCategory($this->site_id, $item_type, $type); - return $res; - } - } - - /** - * 获取分类通过下级 - * @return array - */ - public function getCategoryByParent() - { - if (request()->isAjax()) { - $category = new CategoryModel(); - $level = input('level', 1); - $pid = input('pid', 0); - $type = input('api_type', 'allcategory'); - $cat_type = ''; - $res = $category->getCategoryByParent($this->site_id, $level, $pid, $cat_type, $type); - return $res; - } - } - - - /*** - * 获取全部分类 - * @return array|void - */ - public function getCategory() - { - if (request()->isAjax()) { - $category = new CategoryModel(); - $type = input('api_type', 'allcategory'); - $cat_type = input('cat_type', 1); - $res = $category->getCategory($this->site_id, $type, $cat_type); - return $res; - } - } - - /*** - * 获取模版 - * @return void - */ - public function getTemplate() - { - $category = new CategoryModel(); - $category_id = input('category_id'); - $api_type = input('api_type'); - $item_type = input('item_type'); - $res = $category->getCatTemplate($this->site_id, $category_id, $api_type, $item_type); - return $res; - } -} \ No newline at end of file diff --git a/addon/alilife/shop/controller/Goods.php b/addon/alilife/shop/controller/Goods.php deleted file mode 100644 index 83690d5..0000000 --- a/addon/alilife/shop/controller/Goods.php +++ /dev/null @@ -1,242 +0,0 @@ -isAjax()) { - $goods = new GoodsModel(); - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $keywords = input('keywords', ''); - $goods_id = input('goods_id', ''); - $condition = [ - ['sg.site_id', '=', $this->site_id], - ['sg.api_type', '=', 'allcategory'], - ]; - if ($keywords) { - $condition[] = [ - 'g.goods_name', 'like', "%{$keywords}%" - ]; - } - if ($goods_id) { - $condition[] = [ - 'g.goods_id', '=', $goods_id - ]; - } - $data = $goods->getGoodsPageList($condition, '*', 'id desc', $page, $page_size); - return $data; - } else { - $category = (new Category())->getCategoryByParent($this->site_id, 1, 0, 1); - $category_two = (new Category())->getCategoryByParent($this->site_id, 1, 0, 2); - $category_three = (new Category())->getCategoryByParent($this->site_id, 1, 0, 3); - $this->assign('first_cat_one', $category['data']); - $this->assign('first_cat_two', $category_two['data']); - $this->assign('first_cat_three', $category_three['data']); - $this->assign('Package', $category_three['data']); - $this->forthMenu(); - return $this->fetch("goods/index"); - } - } - - /*** - * 获取本地生活生商品 - * @return array|mixed - */ - public function lifelists() - { - if (request()->isAjax()) { - $goods = new GoodsModel(); - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $condition = [ - 'sg.site_id' => $this->site_id, - 'sg.api_type' => 'localitem', - ]; - $data = $goods->getGoodsPageList($condition, '*', 'id desc', $page, $page_size); - return $data; - } else { - $category = (new Category())->getCategoryByParent($this->site_id, 1, 0, 1, 'localitem'); - $first_cat_two = (new Category())->getCategoryByParent($this->site_id, 1, 0, 2, 'localitem'); - $this->assign('first_cat_one', $category['data']); - $this->assign('first_cat_two', $first_cat_two['data']); - $this->assign('shop_info', $this->shop_info); - $this->forthMenu(); - return $this->fetch("goods/local"); - } - } - - /*** - * 添加商品 - * @return array|void - */ - public function add() - { - if (request()->isAjax()) { - if ($this->shop_info['site_status'] <= 0) { - return error('', '您的店铺已到期'); - } - $param = input(); - if (empty($param)) error('必要参数必填'); - $api_type = input('api_type', 'allcategory'); - $item_type = input('item_type', ''); - $merchant_name = input('merchant_name', ''); - $phone_number = input('phone_number', ''); - $data = [ - 'site_id' => $this->site_id, - 'goods_ids' => $param['goods_ids'], - 'cat_id' => $param['cat_id'], - ]; - $goods_model = new GoodsModel(); - if ($api_type == 'localitem') { - $data = request()->post(); - $data['site_id'] = $this->site_id; - return $goods_model->localitemAddGoods($data, $item_type, $merchant_name, $phone_number); - } else { - return $goods_model->addGoods($data, $api_type); - } - } - $this->assign('shop_info', $this->shop_info); - $api_type = input('api_type', 'localitem'); - $this->assign('api_type', $api_type); - return $this->fetch('goods/add'); - } - - /** - * 修改商品分类 - */ - public function edit() - { - $goods_model = new GoodsModel(); - $api_type = input('api_type', 'localitem'); - if (request()->isAjax()) { - $param = input(); - if (empty($param)) $this->error('必要参数必填'); - $api_type = input('api_type', 'allcategory'); - $data = [ - 'site_id' => $this->site_id, - 'goods_id' => $param['goods_id'], - 'cat_id' => $param['cat_id'], - ]; - if ($api_type == 'localitem') { - $goods_id = input('goods_id'); - $item_type = input('item_type'); - $data = request()->post(); - return $goods_model->updateGoodslocalitemGoods($goods_id, $data, $item_type); - } else { - return $goods_model->updateGoods($data, $api_type); - } - } - if ($api_type == 'localitem') { - $goods_id = input('goods_id'); - $groupbuy_model = new GroupbuyModel(); - //获取团购信息 - $condition = [ - ['pg.goods_id', '=', $goods_id], - ['pg.site_id', '=', $this->site_id], - ['g.goods_state', '=', 1], - ['g.is_delete', '=', 0] - ]; - $groupbuy_info = $groupbuy_model->getGroupbuyInfo($condition)['data']; - $this->assign('groupbuy_info', $groupbuy_info); - $this->assign('shop_info', $this->shop_info); - $this->assign('api_type', $api_type); - $this->assign('category_id', input('category_id')); - return $this->fetch('goods/edit'); - } - } - - /*** - * 同步商家产品 - * @return array - */ - public function sync() - { - $start = input('start', 0); - $api_type = input('api_type', 'allcategory'); - $res = (new GoodsModel())->syncGoods($start, 20, $this->site_id, $api_type); - return $res; - } - - - public function syncGoods() - { - $goods_id = input('goods_id'); - $goods_model = new GoodsModel(); - if (request()->isAjax()) { - $data = request()->post(); - $api_type = input('api_type'); - if ($api_type != 'allcategory') { - $res = $goods_model->PushLocaSyncGoodsInfo($goods_id, $data); - } else { - $res = $goods_model->PushPTSyncGoodsInfo($goods_id, $data); - } - return $res; - } - $join = [ - ['goods g', 'g.goods_id=a.goods_id', 'right'] - ]; - $where = [ - ['g.goods_id', '=', $goods_id] - ]; - $goods_info = $goods_model->getGoodsInfo($where, 'g.*,a.category_id', 'a', $join); - $this->assign('goods_info', $goods_info); - $this->assign('goods_id', $goods_id); - $this->assign('shop_info', $this->shop_info); - $this->assign('alipaycategory_id', $goods_info['category_id'] ?: ''); - return $this->fetch('goods/syncGoods'); - } - - /*** - * 上传库存价格 - * @return array - */ - public function syncrenew() - { - $goods_id = input('goods_id'); - $api_type = input('api_type'); - if ($api_type != 'allcategory') { - $res = (new GoodsModel())->syncLocalitemPrice($goods_id, $this->site_id); - } else { - $res = (new GoodsModel())->syncDtockPrice($goods_id, $this->site_id, $api_type); - } - return $res; - } - - /*** - * 下架 - * @return array - */ - public function goodsDelisting() - { - $out_item_id = input('out_item_id', ''); - $res = (new GoodsModel())->goodsDelisting($out_item_id, $this->site_id); - return $res; - } - - /*** - * 上架 - * @return array - */ - public function listing() - { - $out_item_id = input('out_item_id', ''); - $res = (new GoodsModel())->goodsListing($out_item_id, $this->site_id); - return $res; - } - - /** - * 小程序删除商品 - */ - public function delete() - { - if (request()->isAjax()) { - $goods_model = new GoodsModel(); - return $goods_model->deleteGoods(input('out_item_id', ''), $this->site_id); - } - } -} \ No newline at end of file diff --git a/addon/alilife/shop/controller/Order.php b/addon/alilife/shop/controller/Order.php deleted file mode 100644 index 942d992..0000000 --- a/addon/alilife/shop/controller/Order.php +++ /dev/null @@ -1,105 +0,0 @@ -syncRepair($trade_no, $order_id, $this->site_id); - return $res; - } - - - public function syncDelivery() - { - $order_id = input('order_id', ''); - $order_status = input('order_status', ''); - $order = new OrderModel(); - $res = $order->syncDelivery($order_id, $order_status); - return $res; - } - - /*** - * 直接退款 - * @return null - */ - public function refund() - { - $trade_no = input('trade_no', ''); - $order_id = input('order_id', ''); - $order = new OrderModel(); - $res = $order->refund($trade_no, $order_id, $this->site_id); - return $res; - } - - - /*** - * 获取支付宝对账单 - * @return array|mixed - */ - public function miniOrderItembill() - { - if (request()->isAjax()) { - $goods_model = new GoodsModel(); - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - $condition = [ - 'page_num' => $page, - 'page_size' => $page_size, - ]; - $order_status = input('order_status'); - $settle_status = input('settle_status'); - $create_time = input('create_time'); - $settlement_date = input('settlement_date'); - $service_type_list = input('service_type_list'); - if ($order_status) { - $condition['order_status'] = $order_status; - } - if ($settle_status) { - $condition['settle_status'] = $settle_status; - } - if ($create_time) { - $condition['create_time'] = $create_time; - } - if ($create_time) { - $condition['settlement_date'] = $settlement_date; - } - if ($service_type_list) { - $condition['service_type_list'] = json_encode([$service_type_list]); - } - $res = $goods_model->getBillList($condition, $page, $this->site_id); - return $res; - } - return $this->fetch('bill/lists'); - } - - - /*** - * 确认收货 - * @return array - */ - public function confirmreceipt() - { - if (request()->isAjax()) { - $order_id = input('order_id', ''); - $order = new OrderModel(); - $res = $order->takeDelivery($order_id, 1); - return $res; - } - } - - - public function detail() - { - - - } -} \ No newline at end of file diff --git a/addon/alilife/shop/view/bill/lists.html b/addon/alilife/shop/view/bill/lists.html deleted file mode 100644 index 395e814..0000000 --- a/addon/alilife/shop/view/bill/lists.html +++ /dev/null @@ -1,347 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    -
  • 支付宝公域交易订单对账单
  • -
-
-
-
-
-
-
-
- -
- - -
-
-
- -
- - -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
- -
-
-
-
-
- - - - -{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/alilife/shop/view/category/index.html b/addon/alilife/shop/view/category/index.html deleted file mode 100644 index e51841a..0000000 --- a/addon/alilife/shop/view/category/index.html +++ /dev/null @@ -1,357 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} - -{block name="main"} -
- - -
-
- - -
-
-
-
- - - - - - - -
-
-
正在同步中...
-
-
-{/block} -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/alilife/shop/view/goods/access.html b/addon/alilife/shop/view/goods/access.html deleted file mode 100644 index d799ea6..0000000 --- a/addon/alilife/shop/view/goods/access.html +++ /dev/null @@ -1,288 +0,0 @@ -{extend name="app/shop/view/base.html"/} - -{block name="resources"} - -{/block} - -{block name="main"} -
-
微信视频号
- -
-{/block} - -{block name="script"} - - -{/block} \ No newline at end of file diff --git a/addon/alilife/shop/view/goods/add.html b/addon/alilife/shop/view/goods/add.html deleted file mode 100644 index 3cc05a4..0000000 --- a/addon/alilife/shop/view/goods/add.html +++ /dev/null @@ -1,525 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="main"} -
-
- -
- -
-
首次或分类发生变化请同步分类
-
- -
- -
-
- - -
- - -
- - -
-
-
-
- -
-
- - 已选商品(0 -
-
-
- -
- - -
-
- -
- -
- -
- -
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
-
- - -
- -
-{/block} -{block name="script"} - - - - - - - - - - - - -{/block} \ No newline at end of file diff --git a/addon/alilife/shop/view/goods/edit.html b/addon/alilife/shop/view/goods/edit.html deleted file mode 100644 index 8216499..0000000 --- a/addon/alilife/shop/view/goods/edit.html +++ /dev/null @@ -1,389 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="main"} -
- -
- -
-
-
- {if condition="$groupbuy_info.goods_image"} - - {else/} - - {/if} -
-
-
-
-
- -
{$groupbuy_info.goods_name}
-
- -
- -
- -
-
首次或分类发生变化请同步分类
-
- -
- -
- ¥{$groupbuy_info.price} -
-
- -
- -
-
- -
-
-
-
-

如商品存在多规格,则所有规格均是此价售卖,请谨慎设置

-
-
- -
- -
- - -
-
-

最低购买数量不能小于2

-
-
- -
- -
-
- - -
- - -
- - - -
-
-
- -
- -
- - -
-
-

没有蚂蚁门店去添加

-
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
-
- - -
- -
-{/block} -{block name="script"} - - - - - - - -{/block} \ No newline at end of file diff --git a/addon/alilife/shop/view/goods/index.html b/addon/alilife/shop/view/goods/index.html deleted file mode 100644 index 4f77dc4..0000000 --- a/addon/alilife/shop/view/goods/index.html +++ /dev/null @@ -1,779 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    -
  • 首次添加产品或者新增分类请同步产品分类
  • - {if $shop_info.is_try==1} -
  • 您正在使用{$shop_info.group_name}升级套餐
  • - {/if} -
-
-
-
- - - - -
-
- - - -
-
-
-
- - - - - - - - - - - - - -
-

正在同步中...

-
-
-
-
-{/block} -{block name="script"} - - - - - - -{/block} diff --git a/addon/alilife/shop/view/goods/local.html b/addon/alilife/shop/view/goods/local.html deleted file mode 100644 index bd262e2..0000000 --- a/addon/alilife/shop/view/goods/local.html +++ /dev/null @@ -1,482 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
-

操作提示

-
    -
  • 首次添加产品或者新增分类请同步产品分类
  • - {if $shop_info.is_try==1} -
  • 您正在使用{$shop_info.group_name}升级套餐
  • - {/if} -
-
-
-
- - - -
-
- - - -
-
-
- -
- - - - - - - - - - - - - -
-

正在同步中...

-
-
-
-
-{/block} -{block name="script"} - - -{/block} diff --git a/addon/alilife/shop/view/goods/syncGoods.html b/addon/alilife/shop/view/goods/syncGoods.html deleted file mode 100644 index 94db219..0000000 --- a/addon/alilife/shop/view/goods/syncGoods.html +++ /dev/null @@ -1,255 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - -{/block} -{block name="body"} -
-
- -
-
{$goods_info.goods_name}
-
-
-
- -
- - -
-
-
- -
- - 普通商品(实物) - 普通商品(虚拟) - 本地生活(团购) - 本地生活(代金) - 租聘商品(实物) - -
-
-
- -
- - -
-
选择支付宝分类,商品将自动同步支付宝小程序商品库,首次或无分类您可以同步分类
-
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- 全部门店 - - - - -
-
-
- -
- -
-
-
- -
- -
-

请确保活动期间客服电话畅通

-
-
- -
- -
-
-
- -
- - -
-
-{/block} -{block name="script"} - - - - -{/block} diff --git a/addon/commission/api/controller/Index.php b/addon/commission/api/controller/Index.php deleted file mode 100644 index 9724b00..0000000 --- a/addon/commission/api/controller/Index.php +++ /dev/null @@ -1,126 +0,0 @@ -checkToken(); - if ($token['code'] < 0) return $this->response($token); - $this->params['member_id'] = $this->member_id; - $statistics = (new Legumes())->getStatistics($this->params); - - $statisticsList = [ - // ['title' => '已获得豆','value' => $statistics['reality_get_legumes']], - // ['title' => '积分释放上限','value' => $statistics['integral_upper_limit']], - ['title' => '积分赠送上限','value' => $statistics['not_integral']], - ['title' => '已赠送积分','value' => $statistics['get_integral']], - ['title' => '可用积分','value' => $statistics['used_integral']], - ['title' => '已使用积分','value' => $statistics['use_integral']], - ['title' => '冻结中积分','value' => $statistics['freeze_integral']], - ]; - - return $this->response(success(0,'success',$statisticsList)); - } - /** - * Common: 豆豆积分明细 - 变更记录 - * Author: wu-hui - * Time: 2024/05/11 15:12 - * @return false|string - */ - public function LegumesChangeList(){ - // 用户登录信息 - $token = $this->checkToken(); - if ($token['code'] < 0) return $this->response($token); - // 分页及参数信息 - $page = $this->params['page'] ?? 1; - $this->params['page_size'] = 20; - $this->params['member_id'] = (new Member())->getAllMemberIds((int)$this->member_id); - $result = (new Legumes())->getLegumesLogList($page, $this->params); - - return $this->response($result); - } - /** - * Common: 豆豆积分明细 - 每条信息是否记录 - * Author: wu-hui - * Time: 2024/05/15 15:09 - * @return false|string - */ - public function legumesReleaseLog(){ - $this->params['page_size'] = 20; - $result = (new Legumes())->legumesReleaseLog($this->params); - - return $this->response($result); - } - /** - * Common: 获取流水信息 - * Author: wu-hui - * Time: 2024/05/13 17:20 - * @return false|string - */ - public function accountList(){ - // 用户登录信息 - $token = $this->checkToken(); - if ($token['code'] < 0) return $this->response($token); - // 分页及参数信息 - $page = $this->params['page'] ?? 1; - $this->params['page_size'] = 20; - $this->params['member_id'] = $this->member_id; - $result = (new Account())->accountList($page, $this->params); - - return $this->response($result); - } - /** - * Common: 收益统计 - 统计信息 - * Author: wu-hui - * Time: 2024/05/21 14:08 - * @return false|string - */ - public function accountStatistics(){ - // 用户登录信息 - $token = $this->checkToken(); - if ($token['code'] < 0) return $this->response($token); - // 分页及参数信息 - $result = (new Account())->statistics($this->member_id); - - return $this->response($result); - } - /** - * Common: 收益统计 - 收益列表 - * Author: wu-hui - * Time: 2024/05/21 15:08 - * @return false|string - */ - public function accountListV2(){ - // 用户登录信息 - $token = $this->checkToken(); - if ($token['code'] < 0) return $this->response($token); - // 分页及参数信息 - $this->params['page'] = $this->params['page'] ?? 1; - $this->params['page_size'] = 20; - $this->params['member_id'] = $this->member_id; - // $result = (new Account())->accountListV2($this->params); - $result = (new Account())->accountListV3($this->params); - - return $this->response($result); - } - -} \ No newline at end of file diff --git a/addon/commission/command/Commission.php b/addon/commission/command/Commission.php deleted file mode 100644 index a550c7e..0000000 --- a/addon/commission/command/Commission.php +++ /dev/null @@ -1,47 +0,0 @@ -setName('commission') - ->addArgument('run_type', Argument::OPTIONAL, "运行类型") - ->setDescription('平台抽成相关任务'); - } - - protected function execute(Input $input,Output $output){ - // 参数获取 - $runType = trim($input->getArgument('run_type')); - $runType = $runType ?: ''; - // 根据类型执行对应的操作 - switch($runType){ - // 合伙人佣金结算 - case 'partner_settlement': - trace($runType, '计划任务 - 合伙人佣金周期计算 - 开始处理'); - - (new Partner())->settlementInit(); - break; - // 计算昨天产生的豆豆总数 - case 'compute_legumes': - trace($runType, '计划任务 - 计算昨日产生的豆豆总数 - 开始处理'); - - (new Legumes())->computeYesterdayLegumes(); - break; - default: - trace($runType, '计划任务 - 错误 - 不明确的执行内容'); - break; - } - // $output->writeln('接收参数:'. $runType); - // $output->writeln('success'); - } -} diff --git a/addon/commission/config/diy_view.php b/addon/commission/config/diy_view.php deleted file mode 100644 index bb54e83..0000000 --- a/addon/commission/config/diy_view.php +++ /dev/null @@ -1,31 +0,0 @@ - '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ] - 'template' => [], - // 后台自定义组件——装修 - 'util' => [], - // 自定义页面路径 - 'link' => [], - // 自定义图标库 - 'icon_library' => [], - // uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件 - 'component' => [], - // uni-app 页面,多个逗号隔开 - 'pages' => [], - // 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述' - 'info' => [], - // 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】 - 'theme' => [], - // 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ] - 'data' => [] -]; \ No newline at end of file diff --git a/addon/commission/config/event.php b/addon/commission/config/event.php deleted file mode 100644 index 02a40de..0000000 --- a/addon/commission/config/event.php +++ /dev/null @@ -1,58 +0,0 @@ - [], - 'listen' => [ - //展示活动 - 'ShowPromotion' => [ - 'addon\commission\event\ShowPromotion', - ], - // 下单成功 - 'OrderCreate' => [ - 'addon\commission\event\OrderCreate', - 'addon\commission\event\checkAccountsDivide',//验证积分释放可抵扣佣金 - ], - // 支付成功 - 'OrderPay' => [ - 'addon\commission\event\OrderPay', - ], - // 在线买单支付成功 - 'CashierOrderPay' => [ - 'addon\commission\event\OrderPay', - ], - // 订单完成 - 'OrderComplete' => [ - 'addon\commission\event\OrderComplete', - ], - // 收银台订单完成 - 'CashierOrderComplete' => [ - 'addon\commission\event\OrderComplete', - ], - // 订单退款 - 'OrderRefundFinish' => [ - 'addon\commission\event\OrderRefundFinish', - ], - //订单关闭 - 'OrderClose' => [ - 'addon\commission\event\OrderClose', - ], - 'getDivideAccounts' => [//获取分佣账号 - 'addon\commission\event\getDivideAccounts' - ], - 'checkAccountsAuth' => [ //验证是否参与在线支付分账 - 'addon\commission\event\checkAccountsAuth', - ], - 'DivideMoneyAccounts' => [ //计算托管佣金划扣 - 'addon\commission\event\DivideMoneyAccounts', - ], - // 店铺收入统计 这里统计豆豆积分收入 - 'IncomeStatistics' => [ - 'addon\commission\event\IncomeStatistics', - ], - // 店铺支出统计 这里统计豆豆积分退款返还 - 'DisburseStatistics' => [ - 'addon\commission\event\DisburseStatistics', - ], - ], - 'subscribe' => [], -]; diff --git a/addon/commission/config/info.php b/addon/commission/config/info.php deleted file mode 100644 index 50ebf00..0000000 --- a/addon/commission/config/info.php +++ /dev/null @@ -1,20 +0,0 @@ - 'commission', - 'title' => '平台抽成', - 'description' => '平台抽取订单部分金额,分配给指定角色!', - 'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件 - 'status' => 1, - 'author' => '', - 'version' => '1.0.0', - 'version_no' => '2024042911', - 'content' => '', -]; \ No newline at end of file diff --git a/addon/commission/config/menu_shop.php b/addon/commission/config/menu_shop.php deleted file mode 100644 index 0c40233..0000000 --- a/addon/commission/config/menu_shop.php +++ /dev/null @@ -1,61 +0,0 @@ - 'COMMISSION', - 'title' => '平台抽成', - 'url' => 'commission://shop/index/index', - 'parent' => 'PROMOTION_CENTER', - 'is_show' => 1, - 'sort' => 100, - 'child_list' => [ - [ - 'name' => 'COMMISSION_INDEX', - 'title' => '抽成记录', - 'url' => 'commission://shop/index/index', - 'is_show' => 1, - 'sort' => 1, - ], - [ - 'name' => 'COMMISSION_WEIGHT_VALUE', - 'title' => '权重值管理', - 'url' => 'commission://shop/index/weightValue', - 'is_show' => 1, - 'sort' => 1, - ], - [ - 'name' => 'COMMISSION_PARTNER', - 'title' => '合伙人佣金', - 'url' => 'commission://shop/index/partner', - 'is_show' => 1, - 'sort' => 1, - 'menu_type' => 1 - ], - [ - 'name' => 'COMMISSION_LEGUMES', - 'title' => '豆豆积分', - 'url' => 'commission://shop/index/legumes', - 'is_show' => 1, - 'sort' => 1, - 'menu_type' => 1 - ], - [ - 'name' => 'COMMISSION_ACCOUNT', - 'title' => '流水明细', - 'url' => 'commission://shop/index/accountList', - 'is_show' => 1, - 'sort' => 1, - 'menu_type' => 1 - ], - [ - 'name' => 'COMMISSION_SET', - 'title' => '抽成设置', - 'url' => 'commission://shop/index/set', - 'is_show' => 1, - 'sort' => 1, - ] - ] - ] -]; diff --git a/addon/commission/event/DisburseStatistics.php b/addon/commission/event/DisburseStatistics.php deleted file mode 100644 index b737496..0000000 --- a/addon/commission/event/DisburseStatistics.php +++ /dev/null @@ -1,34 +0,0 @@ -getRefundSum([ - ['site_id', '=', $param['site_id']], - ['refund_money_type', '=', '1,2'], - ['refund_time', 'between', [$param['start_time'],$param['end_time']] ] - ], 'legumes_integral_money')['data']; - - return [ - [ - 'title' => '订单退款返还积分抵扣金额', - 'value' => $money, - 'desc' => '统计时间内,订单退款返还积分抵扣金额之和', - 'url' => 'shop/orderrefund/lists?order_scene=legumes_integral' - ] - ]; - } -} \ No newline at end of file diff --git a/addon/commission/event/DivideMoneyAccounts.php b/addon/commission/event/DivideMoneyAccounts.php deleted file mode 100644 index 45939ff..0000000 --- a/addon/commission/event/DivideMoneyAccounts.php +++ /dev/null @@ -1,31 +0,0 @@ -getList(['order_id' => $goods_ids], 'goods_id,goods_money'); - $dataArr = []; - $Account = new Account(); - foreach ($order_goods_ids as $k => $v) { - $param['goods_money'] = $v['goods_money']; - $param['goods_id'] = $v['goods_id']; - $tempArr = $Account->getDivideOrderCalculate($param); - $dataArr = array_merge($dataArr, $tempArr); - } - if (empty($dataArr)) { - $res = event('OrderPayFinish', $param); //取消订单支状态 - } - return $dataArr; - } catch (\Exception $e) { - return []; - } - } -} diff --git a/addon/commission/event/IncomeStatistics.php b/addon/commission/event/IncomeStatistics.php deleted file mode 100644 index 1eb91a8..0000000 --- a/addon/commission/event/IncomeStatistics.php +++ /dev/null @@ -1,33 +0,0 @@ -getOrderMoneySum([ - ['site_id','=',$param['site_id']], - ['pay_time','between',[$param['start_time'],$param['end_time']]], - ],'legumes_integral_money')['data']; - return [ - [ - 'title' => '积分抵扣金额', - 'value' => $money, - 'desc' => '统计时间内,使用的积分抵扣金额之和', - 'url' => 'shop/order/lists?order_scene=legumes_integral' - ] - ]; - } -} \ No newline at end of file diff --git a/addon/commission/event/Install.php b/addon/commission/event/Install.php deleted file mode 100644 index 3a6046d..0000000 --- a/addon/commission/event/Install.php +++ /dev/null @@ -1,23 +0,0 @@ - 0 && $memberId > 0){ - // 获取退回的记录列表 - $useLegumesLogList = (new Legumes())->getUsedList((int)$memberId,(float)$useLegumesIntegral); - // 循环处理 - $returnComputeIntegral = $useLegumesIntegral;// 计算用 退回积分 - $updateData = []; - foreach($useLegumesLogList as $logInfo){ - // 当前分配信息可退回积分 剩余可退回积分 - $reduce = $returnComputeIntegral < $logInfo['use_integral'] ? $returnComputeIntegral : $logInfo['use_integral']; - $returnComputeIntegral = (float)sprintf("%.2f",$returnComputeIntegral - $reduce); - $updateData[] = [ - 'id' => $logInfo['id'], - 'use_integral' => (float)sprintf("%.2f",$logInfo['use_integral'] - $reduce) - ]; - if($returnComputeIntegral <= 0) break; - } - if($updateData){ - // 修改 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - // 添加用户账单信息变更记录 - $mark = '订单关闭 - 退回使用积分:'.$useLegumesIntegral; - model('commission_account')->add([ - 'site_id' => $siteId, - 'member_id' => $memberId, - 'join_id' => $orderId, - 'account_type' => 'close_legumes_integral', - 'account_type_name' => '积分退回', - 'account_data' => $useLegumesIntegral, - 'status' => 2, - 'remark' => $mark, - ]); - } - } - - }catch(Exception $e){ - trace($e->getMessage(), '平台抽成 - 订单关闭 - 错误'); - } - return success(); - } - - -} \ No newline at end of file diff --git a/addon/commission/event/OrderComplete.php b/addon/commission/event/OrderComplete.php deleted file mode 100644 index b64e643..0000000 --- a/addon/commission/event/OrderComplete.php +++ /dev/null @@ -1,42 +0,0 @@ -update(['status'=>1],[ - ['order_id', '=', $orderId] - ]); - // 结算当前订单的 招商员佣金、推广员佣金 - Queue::push(AccountSettlementJob::class,[ - 'order_id' => (int)$orderId, - 'account_type' => 'merchants_promoter', - ]); - - }catch(Exception $e){ - trace($e->getMessage(), '平台抽成 - 订单完成 - 错误'); - } - - return success(); - } - - -} \ No newline at end of file diff --git a/addon/commission/event/OrderCreate.php b/addon/commission/event/OrderCreate.php deleted file mode 100644 index 0ebe686..0000000 --- a/addon/commission/event/OrderCreate.php +++ /dev/null @@ -1,28 +0,0 @@ - (int)$params['order_id'], - ]); - }catch(Exception $e){ - trace($e->getMessage(), '平台抽成 - 下单成功 - 错误'); - } - return success(); - } -} diff --git a/addon/commission/event/OrderPay.php b/addon/commission/event/OrderPay.php deleted file mode 100644 index 80c9759..0000000 --- a/addon/commission/event/OrderPay.php +++ /dev/null @@ -1,52 +0,0 @@ - (int)$params['member_id'], - 'order_id' => (int)$params['order_id'] - ]); - // 支付成功 - 赠送权重值 - Queue::push(GiveWeightValueJob::class,[ - 'member_id' => (int)$params['member_id'], - 'order_id' => (int)$params['order_id'], - 'site_id' => (int)$params['site_id'] - ]); - // 非普通订单支付成功 减少豆豆积分 - $orderType = model('order')->getValue(['order_id' => (int)$params['order_id']], 'order_type'); - if($orderType != 1){ - Queue::push(UseLegumesIntegralJob::class,[ - 'order_id' => (int)$params['order_id'], - ]); - } - }catch(Exception $e){ - trace($e->getMessage(), '平台抽成 - 支付成功 - 错误'); - } - return success(); - } - - -} diff --git a/addon/commission/event/OrderRefundFinish.php b/addon/commission/event/OrderRefundFinish.php deleted file mode 100644 index 85c940a..0000000 --- a/addon/commission/event/OrderRefundFinish.php +++ /dev/null @@ -1,344 +0,0 @@ -handleCommissionRecord($data['order_goods_id'], $refundRate); - // 退款成功 权重值相关处理 - $this->handleWeightValue($data['order_goods_id'], $refundRate); - // 招商员佣金 & 推广员佣金处理 - $this->HandleCommissionMoney($data['order_goods_id'], $refundRate); - // 合伙人佣金处理 - $this->HandlePartnerMoney($data['order_goods_id'], $refundRate); - // 积分和豆豆处理 - $this->HandleLegumes($data['order_goods_id'], $refundRate); - // 抵扣积分退回 - $this->HandleIntegral($data['order_goods_id'], $refundRate); - } - - Db::commit(); - } - catch(Exception $e){ - Db::rollback(); - $error = [ - 'order_goods_id' => $data['order_goods_id'], - 'msg' => $e->getMessage() - ]; - trace($error, '平台抽成 - 订单退款 - 错误'); - } - return success(0,'平台抽成退款操作完成'); - } - - // 退款处理 - 平台抽成记录处理 - private function handleCommissionRecord($orderGoodsId, $refundRate){ - $hasRefundRatio = (float)model('commission_record')->getValue(['order_goods_id'=>$orderGoodsId],'refund_ratio'); - $updateData = [ - 'refund_ratio' => (float)sprintf("%.2f", $hasRefundRatio + $refundRate) - ]; - if($updateData['refund_ratio'] >= 100){ - $updateData['refund_ratio'] = 100; - $updateData['partner_status'] = 3; - $updateData['merchants_status'] = 3; - $updateData['promoter_status'] = 3; - } - model('commission_record')->update($updateData,[ - ['order_goods_id', '=', $orderGoodsId] - ]); - return true; - } - // 退款处理 - 权重值相关处理 - private function handleWeightValue($orderGoodsId, $refundRate){ - $weightValueLogList = model('commission_weight_value_log')->getList([ - ['order_goods_id', '=', $orderGoodsId], - ['change_type', '=', 1], - ['source', '=', 0], - ],'id,member_id,level_id,order_goods_id,change_quantity,goods_id,order_id'); - $insertLogData = []; - $updateData = []; - foreach($weightValueLogList as $weightValueLogInfo){ - // 获取用户持有信息 - $holdInfo = model('commission_weight_value')->getInfo([ - ['member_id', '=', $weightValueLogInfo['member_id']], - ['level_id', '=', $weightValueLogInfo['level_id']], - ]); - // 获取已经减少数量 - $reduced = model('commission_weight_value_log')->getSum([ - ['order_goods_id', '=', $weightValueLogInfo['order_goods_id']], - ['change_type', '=', 0], - ['source', '=', 1], - ['member_id', '=', $weightValueLogInfo['member_id']], - ], 'change_quantity'); - // 计算减少信息,总减少数量不能超过获取数量 - $reduce = (float)sprintf("%.2f",$weightValueLogInfo['change_quantity'] * $refundRate / 100); - $totalReduce = (float)sprintf("%.2f",$reduced * $reduce); - if($totalReduce > $weightValueLogInfo['change_quantity']) $reduce = (float)sprintf("%.2f",$weightValueLogInfo['change_quantity'] - $reduced); - $changeFront = $holdInfo->quantity; - $surplusQuantity = (float)sprintf("%.2f",$holdInfo['quantity'] - $reduce); - $updateData[] = [ - 'id' => $holdInfo['id'], - 'quantity' => $surplusQuantity - ]; - // 记录变更记录 - $insertLogData[] = [ - 'site_id' => $holdInfo['site_id'], - 'member_id' => $weightValueLogInfo['member_id'], - 'level_id' => $weightValueLogInfo['level_id'], - 'goods_id' => $weightValueLogInfo['goods_id'], - 'order_id' => $weightValueLogInfo['order_id'], - 'order_goods_id' => $weightValueLogInfo['order_goods_id'], - 'change_type' => 0, - 'change_quantity' => $reduce, - 'change_front' => $changeFront, - 'change_after' => (float)$surplusQuantity, - 'remark' => '商品退款,减少权重值', - 'source' => 1, - ]; - } - if(count($insertLogData) > 0){ - model('commission_weight_value_log')->addList($insertLogData); - } - if(count($updateData) > 0){ - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_weight_value', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - } - return true; - } - // 退款处理 - 招商员佣金 & 推广员佣金处理 - private function HandleCommissionMoney($orderGoodsId, $refundRate){ - $where = [ - ['order_goods_id', '=', $orderGoodsId], - ['merchants_status', '=', 1], - ]; - $field = [ - 'a.id', - 'a.site_id', - 'a.store_id', - 'a.order_id', - 'a.order_goods_id', - 'a.merchants_money', - 's.merchants_member_id', - 's.store_name', - 'a.member_id', - 'a.promoter_money', - 'm.is_fenxiao', - 'm.nickname', - 'fx.member_id as fenxiao_member_id', - 'fx.parent' - ]; - $join = [ - ['store s', 's.store_id = a.store_id', 'LEFT'], // 关联客服 - ['member m', 'a.member_id = m.member_id', 'LEFT'], - ['fenxiao fx', 'm.fenxiao_id = fx.fenxiao_id', 'LEFT'], - ]; - $info = model('commission_record')->getInfo($where,$field,'a',$join); - if(!$info) return false; - // 处理招商员佣金 - if((int)$info['merchants_member_id'] > 0){ - // 获取冻结中佣金信息 - $reduce = (float)sprintf("%.3f",$info['merchants_money'] * $refundRate / 100);// 减少数量 - model('commission_account')->add([ - 'site_id' => $info['site_id'], - 'member_id' => $info['merchants_member_id'], - 'join_id' => $info['id'], - 'account_type' => 'merchants_refund', - 'account_type_name' => '招商员佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => '订单退款,减少收入', - 'status' => 2, - ]); - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $info['merchants_member_id']]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $info['merchants_member_id']], - ]); - } - // 处理推广员佣金 - if($info['is_fenxiao'] == 1) $parentMemberId = model('fenxiao')->getValue(['fenxiao_id'=>$info['parent']], 'member_id');// 当前用户是分销商 使用parent查询上级用户id - else $parentMemberId = $info['fenxiao_member_id'];// 当前用户不是分销商 直接为fenxiao_member_id - if($parentMemberId > 0){ - $reduce = (float)sprintf("%.3f",$info['promoter_money'] * $refundRate / 100);// 减少数量 - model('commission_account')->add([ - 'site_id' => $info['site_id'], - 'member_id' => $parentMemberId, - 'join_id' => $info['id'], - 'account_type' => 'promoter_refund', - 'account_type_name' => '推广员佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => '订单退款,减少收入', - 'status' => 2, - ]); - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $parentMemberId]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $parentMemberId], - ]); - } - return true; - } - // 退款处理 - 合伙人佣金处理 - private function HandlePartnerMoney($orderGoodsId, $refundRate){ - $commissionRecord = model('commission_record')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'partner_status,create_time,partner_money'); - // 待结算-结算时处理,已结算-减少用户已获得佣金,2、3-无处理 - if($commissionRecord['partner_status'] == 1){ - // 获取:获取当前抽成结算的归属周期 - $createTime = strtotime($commissionRecord['create_time']); - $cycleInfo = model('commission_partner_cycle')->getInfo([ - ['start_time', '<', $createTime], - ['end_time', '>', $createTime], - ]); - if($cycleInfo){ - // 计算总退款的合伙人佣金 - $reduceCommissionMoney = (float)sprintf("%.3f",$commissionRecord['partner_money'] * $refundRate / 100);// 减少数量 - // 获取退款的用户列表 - $userList = model('commission_partner')->getList([ - ['cycle_id', '=', $cycleInfo['cycle_id']], - ],'id,site_id,member_id,money,proportion,cycle_id'); - $insertData = []; - foreach($userList as $partnerInfo){ - // 计算当前用户应扣除合伙人佣金 - $reduce = (float)sprintf("%.2f",$reduceCommissionMoney * $partnerInfo['proportion'] / 100); - // 记录账单 - $insertData = [ - 'site_id' => $partnerInfo['site_id'], - 'member_id' => $partnerInfo['member_id'], - 'join_id' => $partnerInfo['id'], - 'account_type' => 'partner_refund', - 'account_type_name' => '合伙人佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => "订单退款,减少收入", - 'status' => 2, - ]; - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $partnerInfo['member_id']]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $partnerInfo['member_id']], - ]); - } - // 记录账单变化信息 - if (count($insertData) > 0) model('commission_account')->addList($insertData); - } - } - return true; - } - // 退款处理 - 积分和豆豆处理 - private function HandleLegumes($orderGoodsId, $refundRate){ - // 获取当前抽成信息 - $commissionRecord = model('commission_record')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'id,create_time'); - // 判断:当前抽成豆豆信息是否已经结算,未结算-无操作处理(结算时处理退款内容);已结算-处理退款相关内容 - $maxEndTime = model('commission_legumes')->getMax([],'end_time'); - $createTime = strtotime($commissionRecord['create_time']); - if($createTime < $maxEndTime){ - // 已结算 - 处理退款相关内容 - $legumesId = model('commission_legumes')->getValue([ - ['start_time', '<', $createTime], - ['end_time', '>', $createTime] - ], 'id'); - if($legumesId > 0){ - // 获取需要修改的信息列表 - $correlationList = model('commission_legumes_log')->getList([ - ['legumes_id', '=', $legumesId] - ], 'id,member_id,order_money,refund_order_money,get_legumes,refund_get_legumes,get_integral'); - // 循环处理 - $updateData = []; - foreach($correlationList as $correlationInfo){ - // 计算 退款金额 - $reduceOrderMoney = (float)sprintf("%.2f",$correlationInfo['order_money'] * $refundRate / 100); - $refundOrderMoney = (float)sprintf("%.3f", $correlationInfo['refund_order_money'] + $reduceOrderMoney); - if($refundOrderMoney > $correlationInfo['order_money']) $refundOrderMoney = $correlationInfo['order_money']; - // 计算 退款豆豆 - $reduceGetLegumes = (float)sprintf("%.2f",$correlationInfo['get_legumes'] * $refundRate / 100); - $refundGetLegumes = (float)sprintf("%.3f", $correlationInfo['refund_get_legumes'] + $reduceGetLegumes); - if($refundGetLegumes > $correlationInfo['get_legumes']) $refundGetLegumes = $correlationInfo['get_legumes']; - // 记录修改信息 - $updateData[] = [ - 'id' => $correlationInfo['id'], - 'refund_order_money' => $refundOrderMoney, - 'refund_get_legumes' => $refundGetLegumes - ]; - } - if(count($updateData) > 0) { - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - Queue::push(ComputeIntegralJob::class,[ - 'ids' => array_column($correlationList,'id') - ]); - } - } - } - return true; - } - // 退款处理 - 抵扣积分退回 - private function HandleIntegral($orderGoodsId, $refundRate){ - // 获取订单商品信息 - $orderProductInfo = model('order_goods')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'site_id,member_id,order_id,legumes_integral_use'); - $useLegumesIntegral = $orderProductInfo['legumes_integral_use'] ?? 0; - $memberId = $orderProductInfo['member_id'] ?? 0; - if($useLegumesIntegral > 0 && $memberId > 0){ - // 计算退回积分 - $returnIntegral = (float)sprintf("%.2f",$useLegumesIntegral * $refundRate / 100); - // 获取退回的记录列表 - $useLegumesLogList = (new Legumes())->getUsedList((int)$memberId,(float)$returnIntegral); - // 循环处理 - $returnComputeIntegral = $returnIntegral;// 计算用 退回积分 - $updateData = []; - foreach($useLegumesLogList as $logInfo){ - // 当前分配信息可退回积分 剩余可退回积分 - $reduce = $returnComputeIntegral < $logInfo['use_integral'] ? $returnComputeIntegral : $logInfo['use_integral']; - $returnComputeIntegral = (float)sprintf("%.2f",$returnComputeIntegral - $reduce); - $updateData[] = [ - 'id' => $logInfo['id'], - 'use_integral' => (float)sprintf("%.2f",$logInfo['use_integral'] - $reduce) - ]; - if($returnComputeIntegral <= 0) break; - } - if($updateData){ - // 修改 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - // 添加用户账单信息变更记录 - $mark = '订单退款 - 退回抵扣积分:'.$returnIntegral; - model('commission_account')->add([ - 'site_id' => $orderProductInfo['site_id'], - 'member_id' => $memberId, - 'join_id' => $orderProductInfo['order_id'], - 'account_type' => 'refund_legumes_integral', - 'account_type_name' => '积分退回', - 'account_data' => $returnIntegral, - 'status' => 2, - 'remark' => $mark, - ]); - } - } - - return true; - } - -} diff --git a/addon/commission/event/ShowPromotion.php b/addon/commission/event/ShowPromotion.php deleted file mode 100644 index d5fee8a..0000000 --- a/addon/commission/event/ShowPromotion.php +++ /dev/null @@ -1,34 +0,0 @@ - [ - [ - //插件名称 - 'name' => 'commission', - //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具) - 'show_type' => 'shop', - //展示主题 - 'title' => '平台抽成', - //展示介绍 - 'description' => '平台抽取订单部分金额,分配给指定角色!', - //展示图标 - 'icon' => 'addon/commission/icon.png', - //跳转链接 - 'url' => 'commission://shop/index/index', - ] - ] - ]; - } -} \ No newline at end of file diff --git a/addon/commission/event/UnInstall.php b/addon/commission/event/UnInstall.php deleted file mode 100644 index 8758b17..0000000 --- a/addon/commission/event/UnInstall.php +++ /dev/null @@ -1,24 +0,0 @@ -checkAccountsAuth($param); - } catch (\Exception $e) { - return []; - } - } -} diff --git a/addon/commission/event/checkAccountsDivide.php b/addon/commission/event/checkAccountsDivide.php deleted file mode 100644 index d3b929e..0000000 --- a/addon/commission/event/checkAccountsDivide.php +++ /dev/null @@ -1,17 +0,0 @@ -setCheckAccountsDivide($param); - } catch (\Exception $e) { - return []; - } - } -} diff --git a/addon/commission/event/getDivideAccounts.php b/addon/commission/event/getDivideAccounts.php deleted file mode 100644 index 3342e92..0000000 --- a/addon/commission/event/getDivideAccounts.php +++ /dev/null @@ -1,17 +0,0 @@ -getDivideAccounts($param); - } catch (\Exception $e) { - return []; - } - } -} diff --git a/addon/commission/icon.png b/addon/commission/icon.png deleted file mode 100644 index 97f323c..0000000 Binary files a/addon/commission/icon.png and /dev/null differ diff --git a/addon/commission/job/AccountSettlementJob.php b/addon/commission/job/AccountSettlementJob.php deleted file mode 100644 index 08864dd..0000000 --- a/addon/commission/job/AccountSettlementJob.php +++ /dev/null @@ -1,78 +0,0 @@ -getColumn([ - ['order_id', '=', $data['order_id']] - ],'id'); - $where[] = ['join_id', 'in', $joinIds]; - } - // 流水列表 - $list = model('commission_account')->getList($where,'id,sum(account_data) as total_account_data,member_id','','a',[],'member_id'); - // 获取用户已经持有信息 - $memberIds = array_column($list, 'member_id'); - $userList = Db::name('member') - ->field('commission_money,member_id') - ->whereIn('member_id', $memberIds) - ->select() - ->toArray(); - $userList = array_column($userList, null, 'member_id'); - // 循环流水列表 结算信息 - foreach($list as $singleInfo){ - $userList[$singleInfo['member_id']]['commission_money'] += $singleInfo['total_account_data']; - } - // 修改 - $newBaseModel = (new NewBaseModel(['table_name' => 'member', 'pk' => 'member_id'])); - $userList = array_values($userList); - $newBaseModel->saveAll($userList); - // 已结算 - model('commission_account')->update(['status'=>1],[ - ['id', 'in', array_column($list, 'id')] - ]); - - - Db::commit(); - } - catch(\Exception $e){ - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 流水结算到账 - 失败'); - Db::rollback(); - } - $job->delete(); - } - - public function failed($data){ - trace($data, '平台抽成 - 流水结算到账 - 失败(failed)'); - } -} diff --git a/addon/commission/job/AllocationLegumesJob.php b/addon/commission/job/AllocationLegumesJob.php deleted file mode 100644 index 375a767..0000000 --- a/addon/commission/job/AllocationLegumesJob.php +++ /dev/null @@ -1,91 +0,0 @@ -getInfo(['id' => $legumesId]); - if(!$cycleLegumes) throw new Exception('信息不存在'); - if((int)$cycleLegumes['status'] != 0) throw new Exception('当前豆豆已分配!'); - // 获取时间段所有消费用户 - $where = [ - [ 'a.pay_time', 'between', [ $cycleLegumes['start_time'], $cycleLegumes['end_time'] ] ],// 指定时间段内 - [ 'og.refund_status', 'in', [0, 3] ],// 订单商品未退款 - [ 'a.order_status', 'in', [1, 3, 4, 10, 11, 12] ],//待发货、已发货、已收货、已完成、待使用、已使用 - ]; - $join = [ - [ 'order_goods og', 'og.order_id = a.order_id', 'right' ], - ]; - $field = 'og.order_id,og.order_goods_id,og.member_id,a.order_status,(sum(og.real_goods_money) + sum(og.legumes_integral_money)) as sum_money'; - $orderList = model('order')->getList($where,$field,'','a',$join,'og.order_goods_id'); - $totalMoney = array_sum(array_column($orderList,'sum_money')); - // 获取平台抽成信息 - $orderGoodsIds = array_column($orderList,'order_goods_id'); - $commissionRecord = model('commission_record')->getList([ - ['order_goods_id','in',$orderGoodsIds], - ],'order_goods_id,order_id,member_id,integral_money as platform_commission_money'); - $totalPlatformCommission = array_sum(array_column($commissionRecord,'platform_commission_money')); - $commissionRecord = array_column($commissionRecord,null,'order_goods_id'); - // 循环处理 - $insertData = []; - foreach($orderList as $orderInfo){ - // 获取平台抽成信息 - $platformCommissionInfo = $commissionRecord[$orderInfo['order_goods_id']] ?? []; - if($platformCommissionInfo){ - // 计算订单金额占比 必须进行100的偏移计算 - $rate = (float)sprintf("%.3f",$platformCommissionInfo['platform_commission_money'] / $totalPlatformCommission * 100); - $getLegumes = sprintf("%.4f",$cycleLegumes['legumes_num'] * $rate / 100); - // 信息记录 - $insertData[] = [ - 'member_id' => $orderInfo['member_id'], - 'legumes_id' => $legumesId, - 'order_id' => $orderInfo['order_id'], - 'order_goods_id' => $orderInfo['order_goods_id'], - 'cycle_total_legumes' => $cycleLegumes['legumes_num'], - 'total_sales_money' => $totalMoney, - 'order_money' => $orderInfo['sum_money'], - 'order_money_rate' => $rate, - 'get_legumes' => $getLegumes, - 'status' => in_array((int)$orderInfo['order_status'],[10,12]) ? 1 : 0, - ]; - } - } - // 添加数据 - if(count($insertData) > 0) model('commission_legumes_log')->addList($insertData); - // 修改豆豆周期分配状态 - model('commission_legumes')->update(['status' => 1],[ - ['id', '=', $legumesId] - ]); - // 触发全平台豆豆转积分操作 - Queue::push(ComputeIntegralJob::class); - Db::commit(); - } - catch(\Exception $e){ - Db::rollback(); - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 豆豆分配 - 失败'); - } - $job->delete(); - } - public function failed($data){ - trace($data, '平台抽成 - 豆豆分配 - 失败(failed)'); - } -} diff --git a/addon/commission/job/ComputeIntegralJob.php b/addon/commission/job/ComputeIntegralJob.php deleted file mode 100644 index 337bdc7..0000000 --- a/addon/commission/job/ComputeIntegralJob.php +++ /dev/null @@ -1,92 +0,0 @@ -getLegumesPrice(); - // 获取当前页数据 有效记录、已获取积分低于订单金额 - $where = [ - ['status', 'in', [0,1]] - ]; - if(count($ids) > 0) $where[] = ['id', 'in', $ids]; - else $where[] = ['', 'exp', Db::raw('get_integral < order_money')]; - $field = 'id,(order_money - refund_order_money) as order_money,(get_legumes - refund_get_legumes) as get_legumes,get_integral,member_id'; - $result = model('commission_legumes_log')->pageList($where,$field,'',$page,$limit); - $count = $result['count'] ?? 0; - $list = $result['list'] ?? []; - if(count($list) <= 0) throw new \Exception('无处理数据!'); - // 循环处理 - $updateData = []; - $insertData = []; - foreach($list as $item){ - // 计算最新本订单商品 总释放积分;总释放积分不能超过订单金额 - $getIntegral = (float)sprintf("%.2f",$item['get_legumes'] * $legumesPrice); - $resultGetIntegral = $getIntegral >= $item['order_money'] ? $item['order_money'] : $getIntegral; - // 修改信息记录 - $updateData[] = [ - 'id' => $item['id'], - 'get_integral' => $resultGetIntegral - ]; - // 增加释放记录 仅存在变更数量时记录 - $changeQuantity = (float)sprintf("%.2f",$resultGetIntegral - $item['get_integral']); - if($changeQuantity > 0){ - $insertData[] = [ - 'member_id' => $item['member_id'], - 'legumes_log_id' => $item['id'], - 'change_front' => $item['get_integral'], - 'change_quantity' => (float)sprintf("%.2f",$resultGetIntegral - $item['get_integral']), - 'change_after' => $resultGetIntegral, - ]; - } - } - // 修改 - $newBaseModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $newBaseModel->saveAll($updateData); - // 增加记录 - if(count($insertData) > 0) model('commission_legumes_release_log')->addList($insertData); - // 判断:是否存在下一页 - $currentLimit = $page * $limit; - if($currentLimit < $count){ - $data['page'] = $page + 1; - Queue::push(ComputeIntegralJob::class,$data); - } - - Db::commit(); - } - catch(\Exception $e){ - Db::rollback(); - trace($e->getMessage(), '平台抽成 - 全平台豆豆转积分 - 失败'); - } - $job->delete(); - } - - public function failed($data){ - trace($data, '平台抽成 - 全平台豆豆转积分 - 失败(failed)'); - } -} diff --git a/addon/commission/job/CreateRecordJob.php b/addon/commission/job/CreateRecordJob.php deleted file mode 100644 index 61a9161..0000000 --- a/addon/commission/job/CreateRecordJob.php +++ /dev/null @@ -1,98 +0,0 @@ -getConfig(); - if($adminSet['switch'] != 1) throw new Exception('总平台未开启平台抽成'); - // 当前订单是否已经处理 - $isHas = (int)model('commission_record')->getValue([ - ['order_id', '=', $orderId] - ],'id'); - if($isHas > 0) throw new Exception('当前订单已经处理'); - // 获取订单商品信息 - $field = 'order_goods_id,order_id,site_id,member_id,goods_id,store_id,num,(real_goods_money + legumes_integral_use) as use_money'; - $orderGoodsList = model('order_goods')->getList(['order_id'=>$orderId],$field); - // 循环处理 - $insertData = []; - foreach($orderGoodsList as $orderGoodsInfo){ - $useMoney = $orderGoodsInfo['use_money'] ?? 0; - if($useMoney <= 0) continue;// 当前订单商品有效金额为0 - // 设置获取 - $set = (new Setting())->getFinalSet((int)$orderGoodsInfo['site_id'],(int)$orderGoodsInfo['goods_id']); - if($set['switch'] != 1) continue;// 当前商品不参与平台抽成 - $integralRate = (float)$set['integral_rate'] ?? 0; - $operationsRate = (float)$set['operations_rate'] ?? 0; - $partnerRate = (float)$set['partner_rate'] ?? 0; - $merchantsRate = (float)$set['merchants_rate'] ?? 0; - $promoterRate = (float)$set['promoter_rate'] ?? 0; - // 根据抽成计算类型生成记录信息 - $commissionType = $set['commission_type'] ?? 0;// 抽成计算类型 - $operationsMoney = (float)sprintf("%.3f",$useMoney * $operationsRate / 100);// 运营抽成总金额 - $operationsTechnologyMoney = (float)sprintf("%.3f",$operationsMoney * 0.2);// 运营抽成 - 技术公司所得(20%) - $operationsPlatformMoney = (float)sprintf("%.3f",$operationsMoney - $operationsTechnologyMoney);// 运营抽成 - 平台所得(80%) - - $insertData[] = [ - 'member_id' => $orderGoodsInfo['member_id'], - 'site_id' => $orderGoodsInfo['site_id'], - 'store_id' => $orderGoodsInfo['store_id'], - 'order_id' => $orderGoodsInfo['order_id'], - 'order_goods_id' => $orderGoodsInfo['order_goods_id'], - 'goods_id' => $orderGoodsInfo['goods_id'], - 'real_goods_money' => $useMoney, - // 根据计算类型获取值 抽成类型:0=比例,1=固定金额 - 'integral_rate' => $commissionType == 1 ? -1 : $integralRate, - 'integral_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $integralRate) : sprintf("%.3f",$useMoney * $integralRate / 100), - 'operations_rate' => $operationsRate, - 'operations_money' => $operationsMoney, - 'partner_rate' => $commissionType == 1 ? -1 : $partnerRate, - 'partner_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $partnerRate) : sprintf("%.3f",$useMoney * $partnerRate / 100), - 'merchants_rate' => $commissionType == 1 ? -1 : $merchantsRate, - 'merchants_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $merchantsRate) : sprintf("%.3f",$useMoney * $merchantsRate / 100), - 'promoter_rate' => $commissionType == 1 ? -1 : $promoterRate, - 'promoter_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $promoterRate) : sprintf("%.3f",$useMoney * $promoterRate / 100), - 'operations_technology_money' => (float)$operationsTechnologyMoney, - 'operations_platform_money' => (float)$operationsPlatformMoney, - ]; - } - - if(count($insertData) > 0){ - model('commission_record')->addList($insertData); - // 支付成功 - 抽成记录生成后 - 招商员佣金结算 - Queue::push(MerchantsSettlementJob::class,[ - 'order_id' => (int)$orderId - ]); - // 支付成功 - 抽成记录生成后 - 推广员佣金结算 - Queue::push(PromoterSettlementJob::class,[ - 'order_id' => (int)$orderId, - ]); - } - } - catch(\Exception $e){ - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 支付成功生成抽成记录 - 失败'); - } - - $job->delete(); - } - public function failed($data){ - trace($data, '平台抽成 - 支付成功生成抽成记录 - 失败(failed)'); - } -} diff --git a/addon/commission/job/GiveWeightValueJob.php b/addon/commission/job/GiveWeightValueJob.php deleted file mode 100644 index d3aa051..0000000 --- a/addon/commission/job/GiveWeightValueJob.php +++ /dev/null @@ -1,74 +0,0 @@ -getUserHoldList((int)$data['member_id'], (int)$data['site_id']); - // 获取当前订单中所有商品 - $orderGoodsField = 'order_goods_id,order_id,goods_id,(real_goods_money + legumes_integral_use) as use_money'; - $orderGoodsList = model('order_goods')->getList([['order_id','=', $data['order_id']]], $orderGoodsField); - $updateData = []; - $insertLogData = []; - foreach($userHoldList as $userInfo){ - foreach($orderGoodsList as $goodsInfo){ - // 判断:当前用户是否存在修改记录中 不存在添加修改信息 - if(empty($updateData[$userInfo['id']])){ - $updateData[$userInfo['id']] = [ - 'id' => $userInfo['id'], - 'quantity' => $userInfo['quantity'], - ]; - } - // 持有数量增加 - $changeFront = (float)$updateData[$userInfo['id']]['quantity']; - $updateData[$userInfo['id']]['quantity'] = (float)sprintf("%.2f",(float)$goodsInfo['use_money'] + $changeFront); - // 记录变更记录 - $insertLogData[] = [ - 'site_id' => (int)$data['site_id'], - 'member_id' => $userInfo['member_id'], - 'level_id' => $userInfo['level_id'], - 'goods_id' => $goodsInfo['goods_id'], - 'order_id' => $goodsInfo['order_id'], - 'order_goods_id' => $goodsInfo['order_goods_id'], - 'change_type' => 1, - 'change_quantity' => $goodsInfo['use_money'], - 'change_front' => $changeFront, - 'change_after' => (float)$updateData[$userInfo['id']]['quantity'], - 'remark' => '下线购买商品赠送', - ]; - } - } - // 数据结果处理 - if(count($insertLogData) > 0){ - // 修改 - $updateModel = (new NewBaseModel(['table_name' => 'commission_weight_value', 'pk' => 'id'])); - $updateModel->saveAll($updateData); - model('commission_weight_value_log')->addList($insertLogData); - } - } - catch(\Exception $e){ - $data['error_msg'] = $e->getMessage(); - trace($data, '下单赠送权重值 - 失败'); - } - $job->delete(); - } - public function failed($data){ - trace($data, '下单赠送权重值 - 失败(failed)'); - } -} diff --git a/addon/commission/job/MerchantsSettlementJob.php b/addon/commission/job/MerchantsSettlementJob.php deleted file mode 100644 index 19bd632..0000000 --- a/addon/commission/job/MerchantsSettlementJob.php +++ /dev/null @@ -1,82 +0,0 @@ -startTrans(); - try{ - // trace($data, '平台抽成 - 支付成功招商员佣金结算 - 开始处理'); - $orderId = (int)$data['order_id']; - - $where = [ - ['order_id', '=', $orderId], - ['merchants_status', '=', 0], - ]; - $field = 'a.id,a.site_id,a.store_id,a.order_id,a.merchants_money,s.merchants_member_id,s.store_name'; - $join = [ - ['store s', 's.store_id = a.store_id', 'LEFT'], // 关联客服 - ]; - $list = model('commission_record')->getList($where,$field,'','a',$join); - // 循环处理 - $updateData = []; - $insertData = []; - foreach($list as $recordInfo){ - // 根据是否存在招商员 进行对应的处理 - if((int)$recordInfo['merchants_member_id'] > 0){ - // 存在招商员 招商员佣金结算 - $insertData[] = [ - 'site_id' => $recordInfo['site_id'], - 'member_id' => $recordInfo['merchants_member_id'], - 'join_id' => $recordInfo['id'], - 'account_type' => 'merchants', - 'account_type_name' => '招商员佣金', - 'account_data' => $recordInfo['merchants_money'], - 'remark' => $recordInfo['store_name'] . '的订单收入', - ]; - // 修改信息 - $updateData[] =[ - 'id' => $recordInfo['id'], - 'merchants_status' => 1, - ]; - } - else{ - // 不存在招商员 - $updateData[] =[ - 'id' => $recordInfo['id'], - 'merchants_status' => 2, - ]; - } - } - // 数据结果处理 - if(count($insertData) > 0) model('commission_account')->addList($insertData); - if(count($updateData) > 0){ - $updateModel = (new NewBaseModel(['table_name' => 'commission_record', 'pk' => 'id'])); - $updateModel->saveAll($updateData); - } - - - model("commission_record")->commit(); - } - catch(\Exception $e){ - model("commission_record")->rollback(); - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 支付成功招商员佣金结算 - 失败'); - } - $job->delete(); - } - public function failed($data){ - trace($data, '平台抽成 - 支付成功招商员佣金结算 - 失败(failed)'); - } -} diff --git a/addon/commission/job/PartnerSettlementJob.php b/addon/commission/job/PartnerSettlementJob.php deleted file mode 100644 index af11a71..0000000 --- a/addon/commission/job/PartnerSettlementJob.php +++ /dev/null @@ -1,78 +0,0 @@ -getList([ - ['id', 'in', $cycleIds] - ],'id,start_time,end_time'); - $cycleList = array_column($cycleList, null, 'id'); - // 获取结算记录信息 - $list = model('commission_partner')->getList([ - ['cycle_id', 'in', $cycleIds], - ['is_settlement', '=', 0], - ],'id,member_id,cycle_id,money,site_id'); - if(count($list) > 0){ - $insertData = []; - foreach($list as $singleInfo){ - $cycleInfo = $cycleList[$singleInfo['cycle_id']] ?? []; - $timePeriod = date("Y-m-d H:i:s",$cycleInfo['start_time']) . ' ~ ' . date("Y-m-d H:i:s",$cycleInfo['end_time']); - $insertData[] = [ - 'site_id' => $singleInfo['site_id'], - 'member_id' => $singleInfo['member_id'], - 'join_id' => $singleInfo['id'], - 'account_type' => 'partner', - 'account_type_name' => '合伙人佣金', - 'account_data' => $singleInfo['money'], - 'remark' => $timePeriod . "权重值收入", - ]; - } - // 记录信息 - if(count($insertData) > 0) model('commission_account')->addList($insertData); - // 修改结算状态 - $ids = array_column($list,'id'); - model('commission_partner')->update([ 'is_settlement' => 1],[ - ['id', 'in', $ids] - ]); - - // 结算当前订单的 招商员佣金、推广员佣金 - Queue::push(AccountSettlementJob::class,[ - 'account_type' => 'partner', - ]); - } - - Db::commit(); - } - catch(\Exception $e){ - Db::rollback(); - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 合伙人佣金结算 - 失败'); - } - $job->delete(); - } - - public function failed($data){ - trace($data, '平台抽成 - 合伙人佣金结算 - 失败(failed)'); - } -} diff --git a/addon/commission/job/PromoterSettlementJob.php b/addon/commission/job/PromoterSettlementJob.php deleted file mode 100644 index 4166e43..0000000 --- a/addon/commission/job/PromoterSettlementJob.php +++ /dev/null @@ -1,89 +0,0 @@ -startTrans(); - try{ - // trace($data, '平台抽成 - 支付成功推广员佣金结算 - 开始处理'); - $orderId = (int)$data['order_id']; - // 当前订单 - $where = [ - ['order_id', '=', $orderId], - ['promoter_status', '=', 0], - ]; - $join = [ - ['member m', 'a.member_id = m.member_id', 'LEFT'], - ['fenxiao fx', 'm.fenxiao_id = fx.fenxiao_id', 'LEFT'], - ]; - $field = 'a.id,a.site_id,a.member_id,a.promoter_money,m.is_fenxiao,m.nickname,fx.member_id as fenxiao_member_id,fx.parent'; - $list = model('commission_record')->getList($where,$field,'','a', $join); - // 循环处理 - $updateData = []; - $insertData = []; - foreach($list as $recordInfo){ - // 判断:当前用户是否为分销 获取对应的上级分销商用户id - if($recordInfo['is_fenxiao'] == 1){ - // 当前用户是分销商 使用parent查询上级用户id - $parentMemberId = model('fenxiao')->getValue(['fenxiao_id'=>$recordInfo['parent']], 'member_id'); - }else{ - // 当前用户不是分销商 直接为fenxiao_member_id - $parentMemberId = $recordInfo['fenxiao_member_id']; - } - // 判断:是否存在上级 - if((int)$parentMemberId > 0){ - // 存在上级 - $insertData[] = [ - 'site_id' => $recordInfo['site_id'], - 'member_id' => $parentMemberId, - 'join_id' => $recordInfo['id'], - 'account_type' => 'promoter', - 'account_type_name' => '推广员佣金', - 'account_data' => $recordInfo['promoter_money'], - 'remark' => '推广订单收入', - ]; - // 修改信息 - $updateData[] =[ - 'id' => $recordInfo['id'], - 'promoter_status' => 1, - ]; - }else{ - // 不存在上级 - $updateData[] =[ - 'id' => $recordInfo['id'], - 'promoter_status' => 2, - ]; - } - } - // 数据结果处理 - if(count($insertData) > 0) model('commission_account')->addList($insertData); - if(count($updateData) > 0){ - $updateModel = (new NewBaseModel(['table_name' => 'commission_record', 'pk' => 'id'])); - $updateModel->saveAll($updateData); - } - - model("commission_record")->commit(); - } - catch(\Exception $e){ - model("commission_record")->rollback(); - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 支付成功推广员佣金结算 - 失败'); - } - $job->delete(); - } - public function failed($data){ - trace($data, '平台抽成 - 支付成功推广员佣金结算 - 失败(failed)'); - } -} diff --git a/addon/commission/job/UseLegumesIntegralJob.php b/addon/commission/job/UseLegumesIntegralJob.php deleted file mode 100644 index 52b3ac2..0000000 --- a/addon/commission/job/UseLegumesIntegralJob.php +++ /dev/null @@ -1,74 +0,0 @@ -getInfo([ - ['order_id','=', $data['order_id']], - ['legumes_integral_use','>', 0] - ],'order_id,site_id,member_id,legumes_integral_use,legumes_integral_money'); - if(!$orderInfo) throw new \Exception('信息不存在!'); - $useLegumesIntegral = (float)$orderInfo['legumes_integral_use']; - // 查询需要使用的分配记录 - $useLegumesLogList = (new Legumes())->getUseList((int)$orderInfo['member_id'],(float)$orderInfo['legumes_integral_use']); - // 循环处理 - $updateData = []; - foreach($useLegumesLogList as $logInfo){ - $useIntegral = $useLegumesIntegral >= $logInfo['surplus_integral'] ? (float)$logInfo['surplus_integral'] : (float)$useLegumesIntegral; - $useLegumesIntegral = (float)sprintf("%.2f",$useLegumesIntegral - $useIntegral); - $updateData[] = [ - 'id' => $logInfo['id'], - 'use_integral' => (float)sprintf("%.2f",$logInfo['use_integral'] + $useIntegral) - ]; - if($useLegumesIntegral <= 0) break; - } - // 修改成功信息 - if($updateData){ - // 修改豆豆积分使用信息 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - // 添加用户账单信息变更记录 - $mark = '购买商品使用'.$orderInfo['legumes_integral_use'].'积分抵扣'.floatval($orderInfo['legumes_integral_money']).'元'; - model('commission_account')->add([ - 'site_id' => $orderInfo['site_id'], - 'member_id' => $orderInfo['member_id'], - 'join_id' => $orderInfo['order_id'], - 'account_type' => 'use_legumes_integral', - 'account_type_name' => '积分使用', - 'account_data' => '-'.$orderInfo['legumes_integral_use'], - 'status' => 1, - 'remark' => $mark, - ]); - } -// Db::commit(); - } - catch(\Exception $e){ -// Db::rollback(); - $data['error_msg'] = $e->getMessage(); - trace($data, '平台抽成 - 豆豆积分抵扣处理 - 失败'); - } - $job->delete(); - } - - public function failed($data){ - trace($data, '平台抽成 - 豆豆积分抵扣处理 - 失败(failed)'); - } -} diff --git a/addon/commission/model/Account.php b/addon/commission/model/Account.php deleted file mode 100644 index b0bdeb3..0000000 --- a/addon/commission/model/Account.php +++ /dev/null @@ -1,813 +0,0 @@ -pageList($where, true, 'id DESC', $page, $pageSize); - - return $this->success($result); - } - - /** - * Common: 获取流水信息 - * Author: wu-hui - * Time: 2024/05/21 15:08 - * @param $params - * @return array - */ - public function accountListV2($params) - { - $page = $params['page'] ?? 1; - $pageSize = $params['page_size'] ?? PAGE_LIST_ROWS; - // 生成查询条件 - $where = []; - if (isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['a.member_id', '=', $params['member_id']]; - if (isset($params['account_type']) && $params['account_type'] !== '') { - // all=全部;promoter=推广员佣金;merchants=招商员佣金;partner=合伙人佣金; - switch ($params['account_type']) { - case 'promoter': - $where[] = ['a.account_type', 'in', ['promoter_refund', 'promoter']]; - break; - case 'merchants': - $where[] = ['a.account_type', 'in', ['merchants_refund', 'merchants']]; - break; - case 'partner': - $where[] = ['a.account_type', 'in', ['partner_refund', 'partner']]; - break; - case 'legumes_integral': - $where[] = ['a.account_type', 'in', ['use_legumes_integral', 'close_legumes_integral']]; - break; - default : - $where[] = ['a.account_type', 'in', ['sync', 'partner_refund', 'partner', 'promoter_refund', 'promoter', 'merchants_refund', 'merchants']]; - } - } - if (isset($params['time_type']) && $params['time_type'] !== '' && $params['time_type'] !== 'all') { - // all=全部;day=当日;week=本周;month=本月; - $startTime = $endTime = 0; - switch ($params['time_type']) { - case 'day': - [$startTime, $endTime] = getTimeStamp('today'); - - $where[] = ['a.create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - case 'week': - [$startTime, $endTime] = getTimeStamp('week'); - $where[] = ['a.create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - case 'month': - [$startTime, $endTime] = getTimeStamp('month'); - $where[] = ['a.create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - } - } - if (isset($params['status']) && $params['status'] !== '') $where[] = ['a.status', '=', $params['status']]; - // 流水列表 - $join = [ - ['member m', 'm.member_id = a.member_id', 'left'], - ['site s', 's.site_id = a.site_id', 'left'], - ]; - $field = 'a.*,m.username,m.nickname,m.headimg,s.site_name,s.contacts_name,s.contacts_mobile'; - - $result = model('commission_account')->pageList($where, $field, 'id DESC', $page, $pageSize, 'a', $join); - - return $this->success($result); - } - - /** - * Common: 获取流水信息(平台抽成流水和团队奖励流水合并) - * Author: wu-hui - * Time: 2024/08/13 11:51 - * @param $params - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - */ - public function accountListV3($params) - { - $page = $params['page'] ?? 1; - $pageSize = $params['page_size'] ?? PAGE_LIST_ROWS; - // 生成查询条件 - $where = []; - $unionWhere = []; - if (isset($params['member_id']) && $params['member_id'] !== '') { - $where[] = ['member_id', '=', $params['member_id']]; - $unionWhere[] = ['member_id', '=', $params['member_id']]; - } - if (isset($params['account_type']) && $params['account_type'] !== '') { - // all=全部;promoter=推广员佣金;merchants=招商员佣金;partner=合伙人佣金; - switch ($params['account_type']) { - case 'promoter': - $where[] = ['account_type', 'in', ['promoter_refund', 'promoter']]; - $unionWhere[] = ['id', '=', 0]; - break; - case 'merchants': - $where[] = ['account_type', 'in', ['merchants_refund', 'merchants']]; - $unionWhere[] = ['id', '=', 0]; - break; - case 'partner': - $where[] = ['account_type', 'in', ['partner_refund', 'partner']]; - $unionWhere[] = ['id', '=', 0]; - break; - case 'legumes_integral': - $where[] = ['account_type', 'in', ['use_legumes_integral', 'close_legumes_integral']]; - $unionWhere[] = ['id', '=', 0]; - break; - case 'team': - $where[] = ['id', '=', 0]; - break; - default : - $where[] = ['account_type', 'in', ['sync', 'partner_refund', 'partner', 'promoter_refund', 'promoter', 'merchants_refund', 'merchants']]; - } - } - if (isset($params['time_type']) && $params['time_type'] !== '' && $params['time_type'] !== 'all') { - // all=全部;day=当日;week=本周;month=本月; - $startTime = $endTime = 0; - switch ($params['time_type']) { - case 'day': - [$startTime, $endTime] = getTimeStamp('today'); - - $where[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - $unionWhere[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - case 'week': - [$startTime, $endTime] = getTimeStamp('week'); - $where[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - $unionWhere[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - case 'month': - [$startTime, $endTime] = getTimeStamp('month'); - $where[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - $unionWhere[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - break; - } - } - if (isset($params['status']) && $params['status'] !== '') { - $where[] = ['status', '=', $params['status']]; - $unionWhere[] = ['status', '=', $params['status']]; - } - // 信息查询 - $count = Db::name('commission_account') - ->field(['id']) - ->union(function ($query) use ($unionWhere) { - $query->name('team_account')->field(['id'])->where($unionWhere); - })->where($where)->count(); - - $list = Db::name('commission_account') - ->field(['id', 'create_time', 'account_type', 'status', 'account_data', '"commission" as type']) - ->union(function ($query) use ($unionWhere) { - $query->name('team_account')->field(['id', 'create_time', 'account_type', 'status', 'account_data', '"team" as type'])->where($unionWhere); - }) - ->where($where) - ->order('create_time', 'DESC') - ->page($page, $pageSize) - // ->fetchSql() - ->select() - ->toArray(); - - return $this->success([ - 'count' => $count, - 'list' => $list, - 'page_count' => ceil($count / $pageSize), - ]); - } - - - /** - * Common: 统计信息 - * Author: wu-hui - * Time: 2024/05/21 14:06 - * @param $memberId - * @return array - */ - public function statistics($memberId) - { - // 总获得佣金 - $all = model('commission_account')->getSum([ - ['account_data', '>', 0], - ['member_id', '=', $memberId], - ['account_type', 'in', ['sync', 'promoter', 'merchants', 'partner']], - ], 'account_data'); - // 可提现收益 - $withdrawal = model('member')->getValue([ - ['member_id', '=', $memberId], - ], 'commission_money'); - // 总获得 推广收益 - $totalPromoter = model('commission_account')->getSum([ - ['member_id', '=', $memberId], - ['account_type', '=', 'promoter'] - ], 'account_data'); - // 总获得 招商收益 - $totalMerchants = model('commission_account')->getSum([ - ['member_id', '=', $memberId], - ['account_type', '=', 'merchants'] - ], 'account_data'); - // 总获得 合伙人分红 - $totalPartner = model('commission_account')->getSum([ - ['member_id', '=', $memberId], - ['account_type', '=', 'partner'] - ], 'account_data'); - // 推广收益(推广订单数、推广订单总额、推广收益) - $promoter = Db::name('commission_account') - ->field([ - 'COUNT(DISTINCT cr.order_id) AS promoter_order', - 'sum(cr.real_goods_money) as promoter_order_money', - 'sum(a.account_data) as promoter_account' - ]) - ->alias('a') - ->leftjoin("commission_record cr", "a.join_id = cr.id") - ->where([ - ['a.member_id', '=', $memberId], - ['a.account_type', '=', 'promoter'], - ['cr.id', '>', 0] - ]) - ->findOrEmpty(); - // 招商收益(邀请门店、招商订单总额、招商收益) - $merchants = Db::name('commission_account') - ->field([ - 'sum(cr.real_goods_money) as promoter_order_money', - 'sum(a.account_data) as merchants_account' - ]) - ->alias('a') - ->leftjoin("commission_record cr", "a.join_id = cr.id") - ->where([ - ['a.member_id', '=', $memberId], - ['a.account_type', '=', 'merchants'], - ['cr.id', '>', 0] - ]) - ->findOrEmpty(); - $merchants['total_store'] = model('store')->getCount([ - ['merchants_member_id', '=', $memberId] - ]); - // 合伙人(持有权重值、分红收益) - $partner['hold_weight_value'] = model('commission_weight_value')->getSum([ - ['member_id', '=', $memberId] - ], 'quantity'); - $partner['partner_account'] = model('commission_account')->getSum([ - ['member_id', '=', $memberId], - ['account_type', '=', 'partner'] - ], 'account_data'); - // 团队奖励 - 相关统计 - $teamStatistics = (new Commission())->statistics($memberId); - - - return $this->success([ - 'all' => (float)sprintf("%.2f", $all + $teamStatistics['team_total_award']), - 'withdrawal' => $withdrawal, - 'total_promoter' => $totalPromoter, - 'total_merchants' => $totalMerchants, - 'total_partner' => $totalPartner, - 'promoter' => $promoter, - 'merchants' => $merchants, - 'partner' => $partner, - 'team_statistics' => $teamStatistics - ]); - } - - - /*** - * 检查分账状态 - * @param $params - * @return void - */ - public function checkAccountsAuth($params = []) - { - $accounts = []; - if (isset($params['out_trade_no'])) { - $is_divide = cache($params['out_trade_no']); - if ($is_divide == 1) { - $accounts = $this->checkAccountState($params); - } else if ($is_divide != 'no' || empty($is_divide)) { //预留位置多服务器查询 - $order_model = new OrderCommon(); - $order_info = $order_model->getOrderInfo([['site_id', '=', $params['site_id']], ['out_trade_no', '=', $params['out_trade_no']]])['data']; - $site_id = $params['site_id']; - $set = (new Setting())->getFinalSet((int)$site_id, 0); - if ($set['switch'] == 1) { - $total_rate = $set['integral_rate'] + $set['operations_rate']; //积分托管,营运抽佣总和 - $goods_money = $order_info['goods_money']; - $partner_rate_proxy = $getFinalSet['partner_rate_proxy'] ?? 0; - $merchants_rate_proxy = $getFinalSet['merchants_rate_proxy'] ?? 0; - $promoter_rate_proxy = $getFinalSet['promoter_rate_proxy'] ?? 0; - if ($partner_rate_proxy) { //合伙人佣金发放 - $total_rate += $getFinalSet['partner_rate']; - } - if ($merchants_rate_proxy) {//招商员分佣比例 - $total_rate += $getFinalSet['merchants_rate']; - } - if ($promoter_rate_proxy) { //推广员分佣比例 - $total_rate += $getFinalSet['promoter_rate']; - } - $commission = $goods_money * $total_rate / 100; - if ($commission > $order_info['legumes_integral_money']) {//如果拨出佣金大于抵扣直接使用现金分账 - cache($params['out_trade_no'], 1, 7200); //设置分账状态 - $accounts = $this->checkAccountState($params); - } - } - } - } - return $accounts; - } - - - /*** - * 检查分账状态 - * @param $data - * @return array|string - */ - public function checkAccountState($data = []) - { - $res = event('getDivideAccounts', $data); - $divideStatet = true; - $isDivide = false; - $is_pay_error = ''; - $Accounts = []; - if ($res) { - foreach ($res as $v) { - foreach ($v as $item) { - $Accounts[] = $item; - } - } - $is_commission = array_sum(array_column($Accounts, 'is_commission')); - if ($is_commission <= 0) return '';//剔除免佣账号 - $isDivide = true; - if ($data['pay_type'] == 'alipay') {//验证支付宝是否开启分账 - $is_pay_error = cache('is_pay_error' . $data['site_id']); - if (!cache('alipayTradeBatchquery' . $data['site_id']) || $is_pay_error) { - $micode = new MinCode($data['site_id']); - $request = $micode->requestApi('alipay.trade.royalty.relation.batchquery', ['out_request_no' => date('YmdHisw')])['alipay_trade_royalty_relation_batchquery_response']; - if ($request['code'] == 10000) { - cache('alipayTradeBatchquery' . $data['site_id'], 1, 7200); - cache('is_pay_error' . $data['site_id'], null); - } else { - $divideStatet = false; - $is_pay_error = '未检开启分账权限'; - } - } - } - $startTime = mktime(0, 0, 0, date('m'), date('d') - 30, date('Y')); - $where = [ - ['site_id', '=', $data['site_id']], - ['states', 'in', [0, 2, 3]], - ['is_order_account_locking', '=', 0], - ['create_time', '<', $startTime], - ]; - $countMone = model('dividemoney_bill')->getSum($where, 'amount'); - if ($countMone >= 50) { - $divideStatet = false; - $is_pay_error = '服务佣金未结清'; - } - } - return [ - 'isDivide' => $isDivide, - 'divideState' => $divideStatet, - 'err_msg' => $is_pay_error, - ]; - } - - /*** - * 获取分账账号 - * @param $params - * @return array - */ - public function getDivideAccounts($params = [], $proxyFee = 0, $reason = '') - { - $site_id = $params['site_id']; - $pay_type = $params['pay_type']; - $json = [ - ['website w', 's.agent_id=w.site_id', 'inner'], - ]; - $field = 's.is_ispfee,s.service_fee,w.site_id,w.web_contacts,w.web_phone,w.settlement_wecaht_mch_id,w.settlement_alipay_account,w.alipay_account_name,w.wecaht_account_name,w.is_divide,w.separate_accounts_value'; - $siteInfo = model('site')->getInfo(['s.site_id' => $site_id], $field, 's', $json); - $accounts = []; - if ($siteInfo && $siteInfo['is_divide'] == 1) { - $getSet = (new Setting())->getFinalSet((int)$site_id, 0); - $platform = config('accounts'); - $operations_rate = $getSet['operations_rate'];//运营抽佣 - if ($siteInfo['is_ispfee'] == 1) { - $acc1 = [ - 'is_commission' => 1, - 'is_platform' => 1, - 'account_type' => 'technology', - 'agent_id' => $siteInfo['site_id'], - 'realname' => $platform['realname'], - 'mobile' => $platform['mobile'], - 'alipay_account_name' => $platform['alipay']['realname'], - 'settlement_alipay_account' => $platform['alipay']['account'], - 'wecaht_account_name' => $platform['weapp']['realname'], - 'settlement_wecaht_mch_id' => $platform['weapp']['account'], - 'fee_commission' => 0.6, - 'commission_type' => 'sale', - 'separate_accounts' => $platform, - 'reason' => '平台技术服务费0.6%' - ]; - $cisp_fee = $siteInfo['service_fee'] ?? 0; - if ($cisp_fee > 0) {//如果技术费独立设置 - $acc1['fee_commission'] = $cisp_fee; - $acc1['reason'] = "平台技术服务费{$cisp_fee}%"; - } else { - $fee_commission = $platform['default']; - $service_fee = $operations_rate * $fee_commission / 100; - $acc1['fee_commission'] = $service_fee; - $acc1['reason'] = "平台技术服务费{$service_fee}%"; - $operations_rate -= $service_fee; - } - $accounts[] = $acc1; - } - $integral_rate = $getSet['integral_rate'] ?? 0; - $acc2 = [ - 'is_commission' => 1, - 'account_type' => 'integral', - 'agent_id' => $siteInfo['site_id'], - 'realname' => $siteInfo['wecaht_account_name'], - 'mobile' => $siteInfo['web_phone'], - 'alipay_account_name' => $siteInfo['alipay_account_name'], - 'settlement_alipay_account' => $siteInfo['settlement_alipay_account'], - 'wecaht_account_name' => $siteInfo['wecaht_account_name'], - 'settlement_wecaht_mch_id' => $siteInfo['settlement_wecaht_mch_id'], - 'fee_commission' => $integral_rate + $proxyFee, - 'commission_type' => 'sale', - 'is_platform' => 1, - 'separate_accounts' => json_decode($siteInfo['separate_accounts_value'], true), - 'reason' => "消费托管(含:积分托管{$integral_rate}%运营{$operations_rate}%{$reason})" - ]; - $acc2['fee_commission'] += $operations_rate; - $accounts[] = $acc2; - } - $where = [ - ['site_id', '=', $site_id], - ]; - switch ($pay_type) { - case 'wechatpay': - $account = array_column($accounts, 'settlement_wecaht_mch_id'); - $where[] = ['channel_type', '=', 'wechatpay']; - $where[] = ['account', 'in', $account]; - break; - case 'alipay': - $account = array_column($accounts, 'settlement_alipay_account'); - $where[] = ['channel_type', '=', 'alipay']; - $where[] = ['account', 'in', $account]; - break; - case 'cywechatpay': - case 'cyalipay': - $separate_accounts = array_column($accounts, 'separate_accounts'); - $cypay = array_column($separate_accounts, 'cypay'); - $account = array_column($cypay, 'account'); - $where[] = ['channel_type', '=', 'cypay']; - $where[] = ['account', 'in', $account]; - break; - default: - return $accounts; - } - $res = model('dividemoney_account')->getColumn($where, '*', 'account'); - $model = new DividemoneyAccount(); - foreach ($accounts as $k => &$v) { - $account = ''; - $data = [ - 'is_system' => 1, - 'is_platform' => 1, - ]; - if ($pay_type == 'wechatpay') { - $account = $res[$v['settlement_wecaht_mch_id']] ?? []; - $data['account'] = $v['settlement_wecaht_mch_id']; - $data['account_type'] = 'MERCHANT_ID'; - $data['channel_type'] = 'wechatpay'; - $data['realname'] = $v['wecaht_account_name']; - $class = 'BingWechatAccount'; - } else if ($pay_type == 'alipay') { - $account = $res[$v['settlement_alipay_account']] ?? []; - $data['account'] = $v['settlement_alipay_account']; - $data['account_type'] = 'userId'; - $data['channel_type'] = 'alipay'; - $data['realname'] = $v['alipay_account_name']; - $class = 'BingAlipayAccount'; - } else if ($pay_type == 'cywechatpay' || $pay_type == 'cyalipay') { - $cypay = $v['separate_accounts']['cypay']; - $account = $res[$cypay['account']] ?? []; - $data['account'] = $cypay['account']; - $data['account_type'] = 'PARTNER'; - $data['channel_type'] = 'cypay'; - $data['realname'] = $cypay['realname']; - $class = 'BingCyPayAccount'; - } - if (empty($account) || ($account && $account['states'] != 1)) { - $bing = $model->$class($site_id, $data); - if ($bing['code'] >= 0) { - $v['is_auth'] = 1; - } else { - $v['is_auth'] = 0; - } - } else if ($account && $account['states'] == 1) { - $v['is_auth'] = 1; - } - } - return $accounts; - } - - public $legumes_integral_community = 0;//积分佣金循环共存 - - /*** - * 获取账单分佣 - * @param $params - * @return array - */ - public function getDivideOrderCalculate($params = []) - { - $site_id = $params['site_id']; - $pay_type = $params['pay_type']; - $goods_id = $params['goods_id'] ?? 0; - $getFinalSet = (new Setting())->getFinalSet((int)$site_id, $goods_id); - if ($getFinalSet['switch'] == 1) { - $total_rate = $getFinalSet['integral_rate'] + $getFinalSet['operations_rate']; //消费积分托管+营运抽佣总和 - $partner_rate_proxy = $getFinalSet['partner_rate_proxy'] ?? 0; - $merchants_rate_proxy = $getFinalSet['merchants_rate_proxy'] ?? 0; - $promoter_rate_proxy = $getFinalSet['promoter_rate_proxy'] ?? 0; - $reason = ''; - $proxy = 0; - if ($partner_rate_proxy) { //合伙人佣金发放 - $total_rate += $getFinalSet['partner_rate']; - $proxy += $getFinalSet['partner_rate']; - $reason = "合伙人佣金{$getFinalSet['partner_rate']}%"; - } - if ($merchants_rate_proxy) {//招商员分佣比例 - $total_rate += $getFinalSet['merchants_rate']; - $proxy += $getFinalSet['merchants_rate']; - $reason .= "招商佣金{$getFinalSet['merchants_rate']}%"; - } - if ($promoter_rate_proxy) { //推广员分佣比例 - $total_rate += $getFinalSet['promoter_rate']; - $proxy += $getFinalSet['promoter_rate']; - $reason .= "推广佣金{$getFinalSet['promoter_rate']}%"; - } - $goods_money = $params['goods_money']; - $commission = $goods_money * $total_rate / 100; //佣金 - $AccInfo = $this->getDivideAccounts($params, $proxy, $reason); - $accArr = []; - switch ($pay_type) { - case 'cyalipay': - case 'cywechatpay': - $account_type = 'PARTNER'; - break; - case 'wechatpay': - $account_type = 'MERCHANT_ID'; - break; - case 'alipay': - $account_type = 'userId'; - break; - default: - $account_type = 'Integral'; - break; - } - if ($pay_type != 'BALANCE' && $params['legumes_integral_money'] == 0) { - //如果未使用积分抵扣在线支付 - foreach ($AccInfo as $k => $v) { - $v['account_type'] = $account_type; - $arr = $this->getMoneyArr($params, $v, $goods_money, $v['fee_commission'], 1, $v['reason']); - if ($arr) { - $accArr[] = $arr; - } - } - } else if ($pay_type == 'BALANCE' || ($params['legumes_integral_money'] && $params['legumes_integral_money'] >= $commission)) { - //如果抵扣积分大于佣金或使用余额直接使用积分抵扣 - foreach ($AccInfo as $k => $v) { - $v['account_type'] = 'Integral'; - $arr = $this->getMoneyArr($params, $v, $goods_money, $v['fee_commission'], 1, $v['reason']); - if ($arr) { - $accArr[] = $arr; - } - } - $amount = array_sum(array_column($accArr, 'amount')); - $this->legumes_integral_community += $amount; -// model('order')->update(['legumes_integral_community' => Db::raw('legumes_integral_community +' . $amount)], ['order_id' => $params['order_id']]); - } else {//使用积分+支付 - $use_order_money = $params['order_money'] * 0.3;//最大分账率 - $legumes_integral_money = $params['legumes_integral_money'];//使用积分抵扣金额 - $legumes_integral_community = 0; //积分抽佣 - //测试示例 -// $commission = 5; -// $legumes_integral_money = 0.8; -// $use_order_money = 2; - foreach ($AccInfo as $k => $v) { - $getMoney = $this->getMoneyArr($params, $v, $goods_money, $v['fee_commission'], 1, $v['reason']); - if (empty($getMoney)) continue; - if ($pay_type != 'BALANCE' && $commission <= $use_order_money) { //如果佣金大于可抽佣金额直接抽现金 - $getMoney['account_type'] = $account_type; - $accArr[] = $getMoney; - } else if ($pay_type == 'BALANCE') { //如果使用余额支付积分抵扣,可能积分是负数,在未结算总额扣除 - $v['account_type'] = 'Integral'; - $accArr[] = $this->getMoneyArr($params, $v, $goods_money, $v['fee_commission'], 1, $v['reason']); - } else if ($legumes_integral_money) { //如果使用积分抵扣大于佣金 - if ($getMoney['amount'] <= $legumes_integral_money) { //如果积分抵扣大于佣金 - $getMoney['account_type'] = 'Integral'; - $legumes_integral_money -= $getMoney['amount']; - $legumes_integral_community += $getMoney['amount']; - $accArr[] = $getMoney; - } else { - $amount = $getMoney['amount']; - if ($amount > $legumes_integral_money) { //抵扣剩余积分 - $amount -= $legumes_integral_money; - $getMoney['account_type'] = 'Integral'; - $getMoney['amount'] = $legumes_integral_money; - $legumes_integral_community += $legumes_integral_money; - $legumes_integral_money = 0; - $accArr[] = $getMoney; - } - if ($amount > 0) { //扣除支付分账 - $getMoney['account_type'] = $account_type; - $getMoney['amount'] = $amount; - $use_order_money -= $amount; - $accArr[] = $getMoney; - } - } - } else if ($pay_type != 'BALANCE' && $use_order_money) { - $amount = $getMoney['amount']; - if ($use_order_money >= $amount) { - $getMoney['account_type'] = $account_type; - $getMoney['amount'] = $amount; - $accArr[] = $getMoney; - } else if ($use_order_money < $amount) { - if ($use_order_money > 0) { - $getMoney['account_type'] = $account_type; - $getMoney['amount'] = $use_order_money; - $accArr[] = $getMoney; - $amount -= $use_order_money; - $use_order_money = 0; - } - if ($amount > 0) { - $getMoney['account_type'] = 'Integral'; - $getMoney['amount'] = $amount; - $legumes_integral_community += $amount; - $accArr[] = $getMoney; - } - } - } else { //理论上不会出现 - $getMoney['account_type'] = 'Integral'; - $legumes_integral_community += $getMoney['amount']; - $accArr[] = $getMoney; - } - } - $this->legumes_integral_community += $legumes_integral_community;//记录循环值防止重复计算 - } - if ($this->legumes_integral_community > 0) {//防止重复计算 - model('order')->update(['legumes_integral_community' => $this->legumes_integral_community], ['order_id' => $params['order_id']]); - } - } - //如果拨出佣金大于抵扣直接使用现金分账 - return $accArr; - } - - - /*** - * 整理数据 - * @param $data - * @param $accIfno - * @param $price - * @param $fee_commission - * @param $platform_type - * @param $reason - * @return array - */ - private function getMoneyArr($data, $accIfno, $price, $fee_commission, $platform_type = 2, $reason = '服务商服务费') - { - if (isset($accIfno['commission_type']) && $accIfno['commission_type'] == 'fixfee') { - $money = $fee_commission; - } else { - $money = $price * $fee_commission / 100; - if ($money < 0.01) { - $money = 0.01; - } - } - //判断是否按产品抽佣 - $ag_site_id = $data['agent_id'] ?? 0; - $acc = [ - 'site_id' => $data['site_id'], - 'ag_site_id' => $ag_site_id, - 'is_platform' => $platform_type, - 'order_id' => $data['order_id'], - 'member_id' => $data['member_id'], - 'out_trade_no' => $data['out_trade_no'], - 'trade_no' => $data['trade_no'] ?? '', //订单号 - 'is_video_number' => $data['is_video_number'] ?: 0, - 'fee_commission' => $fee_commission, - 'pay_money' => $price,//支付金额, - 'amount' => $money, - 'account_type' => $accIfno['account_type'], - 'channel_type' => $data['pay_type'], - 'promotion_type' => $data['promotion_type'], - 'reason' => $reason - ]; - switch ($data['pay_type']) { - case 'weapp': - case 'wechat': - case 'wechatpay': - $acc['channel_type'] = 'wechatpay'; - $acc['realname'] = $accIfno['wecaht_account_name']; - $acc['account'] = $accIfno['settlement_wecaht_mch_id']; - break; - case 'alipay': - case 'aliapp': - case 'zmxxpay': - case 'huabie': - case 'zmgopay': - $acc['channel_type'] = 'alipay'; - $acc['realname'] = $accIfno['alipay_account_name']; - $acc['account'] = $accIfno['settlement_alipay_account']; - break; - case 'cywechatpay': - case 'cyalipay': - $accounts = $accIfno['separate_accounts']['cypay']; - $acc['realname'] = $accounts['realname']; - $acc['account'] = $accounts['account']; - $acc['channel_type'] = 'cypay'; - break; - case 'hfwechatpay': - case 'hfalipay': - $accounts = $accIfno['separate_accounts']['hfpay']; - $acc['realname'] = $accounts['realname']; - $acc['account'] = $accounts['account']; - $acc['channel_type'] = 'hfpay'; - break; - case 'BALANCE': - $acc['channel_type'] = 'BALANCE'; - $acc['realname'] = $accIfno['realname']; - $acc['account'] = $accIfno['settlement_wecaht_mch_id']; - break; - default: - $accounts = $accIfno['separate_accounts']['Integral']; - $acc['realname'] = $accounts['realname']; - $acc['account'] = $accounts['account']; - $acc['channel_type'] = 'Integral'; - } - $account_type = $acc['account_type']; - if ($account_type == 'Integral') { - $accounts = $accIfno['separate_accounts']['Integral']; - $acc['realname'] = $accounts['realname']; - $acc['account'] = $accounts['account']; - $acc['channel_type'] = 'Integral'; - } - if ($money <= 0 || !$acc['account'] || !$acc['realname']) { //未设置账号不分佣 - $acc = []; - } - return $acc; - } - - /*** - * 设置标记是否该订单参与现金分账 - * @param $params - * @return void - */ - public function setCheckAccountsDivide($params = []) - { - $order_id = $params['order_id']; - $order_model = new OrderCommon(); - $order_info = $order_model->getOrderInfo([['order_id', '=', $order_id]])['data']; - $site_id = $params['site_id']; - $set = (new Setting())->getFinalSet((int)$site_id, 0); - if ($set['switch'] == 1) { - $total_rate = $set['integral_rate'] + $set['operations_rate']; //积分托管,营运抽佣总和 - $goods_money = $order_info['goods_money']; - $commission = $goods_money * $total_rate / 100; - if ($commission > $order_info['legumes_integral_money']) {//如果拨出佣金大于抵扣直接使用现金分账 - cache($order_info['out_trade_no'], 1, 7200); //设置分账状态 - } else { - cache($order_info['out_trade_no'], 'no', 7200); //设置分账状态 - } - } - return $this->success(); - } -} diff --git a/addon/commission/model/CommissionRecord.php b/addon/commission/model/CommissionRecord.php deleted file mode 100644 index 57b316f..0000000 --- a/addon/commission/model/CommissionRecord.php +++ /dev/null @@ -1,118 +0,0 @@ -adminSiteId) $params['site_id'] = $siteId; - // 生成查询条件 - $where = []; - if(isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['a.member_id','=',$params['member_id']]; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['a.site_id','=',$params['site_id']]; - if(isset($params['store_id']) && $params['store_id'] !== '') $where[] = ['a.store_id','=',$params['store_id']]; - if(isset($params['order_id']) && $params['order_id'] !== '') $where[] = ['a.order_id','=',$params['order_id']]; - if(isset($params['order_no']) && $params['order_no'] !== '') $where[] = ['o.order_no','=',$params['order_no']]; - if(isset($params['goods_id']) && $params['goods_id'] !== '') $where[] = ['a.goods_id','=',$params['goods_id']]; - // 关联查询 - $join = [ - [ 'member m', 'm.member_id = a.member_id', 'left' ], - [ 'order o', 'o.order_id = a.order_id', 'left' ], - [ 'goods g', 'g.goods_id = a.goods_id', 'left' ], - [ 'site s', 's.site_id = a.site_id', 'left' ] - ]; - $field = [ - 'a.id', - 'a.real_goods_money', - 'a.integral_rate', - 'a.integral_money', - 'a.operations_rate', - 'a.operations_money', - 'a.operations_technology_money', - 'a.operations_platform_money', - 'a.partner_rate', - 'a.partner_money', - 'a.partner_status', - 'a.merchants_rate', - 'a.merchants_money', - 'a.merchants_status', - 'a.promoter_rate', - 'a.promoter_money', - 'a.promoter_status', - 'a.create_time', - 'a.refund_ratio', - 'm.member_id', - 'm.nickname', - 'm.username', - 'm.headimg', - 'o.order_id', - 'o.order_no', - 'o.order_type', - 'g.goods_id', - 'g.goods_name', - 'g.goods_image', - 's.site_name', - 's.contacts_name', - 's.contacts_mobile', - ]; - $result = model('commission_record')->pageList($where,$field,'a.id DESC',$page,PAGE_LIST_ROWS,'a',$join); - $result['is_admin'] = $siteId == $this->adminSiteId; - - return $this->success($result); - } - /** - * Common: 获取统计信息 - * Author: wu-hui - * Time: 2024/05/13 9:43 - * @param $params - * @param $siteId - * @return array - */ - public function getStatistics($params, $siteId){ - // 判断:不是总平台 仅显示当前店铺相关抽成记录 - if($siteId != $this->adminSiteId) $params['site_id'] = $siteId; - // 生成查询条件 - $where = []; - if(isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['a.member_id','=',$params['member_id']]; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['a.site_id','=',$params['site_id']]; - if(isset($params['store_id']) && $params['store_id'] !== '') $where[] = ['a.store_id','=',$params['store_id']]; - if(isset($params['order_id']) && $params['order_id'] !== '') $where[] = ['a.order_id','=',$params['order_id']]; - if(isset($params['order_no']) && $params['order_no'] !== '') $where[] = ['o.order_no','=',$params['order_no']]; - if(isset($params['goods_id']) && $params['goods_id'] !== '') $where[] = ['a.goods_id','=',$params['goods_id']]; - // 关联查询 - $join = [ - [ 'order o', 'o.order_id = a.order_id', 'left' ], - ]; - // 信息统计 - return [ - 'total_real_goods_money' => model('commission_record')->getSum($where,'real_goods_money','a',$join), - 'total_integral_money' => model('commission_record')->getSum($where,'integral_money','a',$join), - 'total_operations_money' => model('commission_record')->getSum($where,'operations_money','a',$join), - 'total_partner_money' => model('commission_record')->getSum($where,'partner_money','a',$join), - 'total_merchants_money' => model('commission_record')->getSum($where,'merchants_money','a',$join), - 'total_promoter_money' => model('commission_record')->getSum($where,'promoter_money','a',$join), - ]; - } - - -} \ No newline at end of file diff --git a/addon/commission/model/Legumes.php b/addon/commission/model/Legumes.php deleted file mode 100644 index dc45cac..0000000 --- a/addon/commission/model/Legumes.php +++ /dev/null @@ -1,464 +0,0 @@ - model('commission_legumes_log')->getSum($where, 'get_legumes'), - 'total_order_money' => model('commission_legumes_log')->getSum($where, 'order_money'), - 'total_get_integral' => model('commission_legumes_log')->getSum($where, 'get_integral'), - 'total_use_integral' => model('commission_legumes_log')->getSum($where, 'use_integral'), - 'total_freeze_integral' => model('commission_legumes_log')->getSum($freezeWhere, 'get_integral'), - ]; - } - - /** - * Common: 获取豆豆周期结算信息 - * Author: wu-hui - * Time: 2024/05/09 11:49 - * @param $page - * @param $params - * @return array - */ - public function getCycleList($page, $params) - { - // 生成查询条件 - $where = []; - // 关联查询 - $result = model('commission_legumes')->pageList($where, true, 'id DESC', $page, PAGE_LIST_ROWS); - - return $this->success($result); - } - - /** - * Common: 获取豆豆分配明细 - * Author: wu-hui - * Time: 2024/05/09 11:58 - * @param $page - * @param $params - * @return array - */ - public function getLegumesLogList($page, $params) - { - $pageSize = $params['page_size'] ?? PAGE_LIST_ROWS; - // 生成查询条件 - $where = []; - if (isset($params['member_id']) && $params['member_id'] !== '') { - if (is_array($params['member_id'])) $where[] = ['a.member_id', 'in', $params['member_id']]; - else $where[] = ['a.member_id', '=', $params['member_id']]; - } - if (isset($params['legumes_id']) && $params['legumes_id'] !== '') $where[] = ['a.legumes_id', '=', $params['legumes_id']]; - if (isset($params['status']) && $params['status'] !== '') $where[] = ['a.status', '=', $params['status']]; - // 关联查询 - $join = [ - ['member m', 'm.member_id = a.member_id', 'left'], - ]; - $field = [ - 'a.*', - 'm.nickname', - 'm.username', - 'm.headimg', - ]; - $result = model('commission_legumes_log')->pageList($where, $field, 'id DESC', $page, $pageSize, 'a', $join); - - return $this->success($result); - } - - /** - * Common: 获取积分释放明细 - * Author: wu-hui - * Time: 2024/05/15 15:06 - * @param $params - * @return array - */ - public function legumesReleaseLog($params) - { - $pageSize = $params['page_size'] ?? PAGE_LIST_ROWS; - $page = $params['page'] ?? 1; - // 生成查询条件 - $where = []; - if (isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['member_id', '=', $params['member_id']]; - if (isset($params['legumes_log_id']) && $params['legumes_log_id'] !== '') $where[] = ['legumes_log_id', '=', $params['legumes_log_id']]; - // 关联查询 - $result = model('commission_legumes_release_log')->pageList($where, true, 'id DESC', $page, $pageSize); - - return $this->success($result); - } - - /** - * Common: 获取用户持有信息 - * Author: wu-hui - * Time: 2024/05/09 13:45 - * @param $page - * @param $params - * @return array - */ - public function getHoldList($page, $params) - { - $result = $this->getHoldListData($page, $params); - - return $this->success($result); - } - - /** - * Common: 获取用户持有信息(返回信息数组) - * Author: wu-hui - * Time: 2024/05/29 11:23 - * @return mixed - */ - public function getHoldListData($page, $params) - { - // 生成查询条件 - $where = [ - ['a.status', 'in', [0, 1]], - ]; - if (isset($params['member_id']) && $params['member_id'] !== '') { - if (is_array($params['member_id'])) $where[] = ['a.member_id', 'in', $params['member_id']]; - else $where[] = ['a.member_id', '=', $params['member_id']]; - } - // 关联查询 - $join = [ - ['member m', 'm.member_id = a.member_id', 'left'], - ]; - $field = [ - 'a.member_id', - 'sum(a.order_money) as total_order_money', - 'sum(a.get_legumes) as total_get_legumes', - 'sum(a.refund_order_money) as total_refund_order_money', - 'sum(a.refund_get_legumes) as total_refund_get_legumes', - 'sum(a.get_integral) as total_get_integral', - 'sum(a.use_integral) as total_use_integral', - 'm.nickname', - 'm.username', - 'm.headimg', - ]; - $result = model('commission_legumes_log')->pageList($where, $field, 'id DESC', $page, PAGE_LIST_ROWS, 'a', $join, 'a.member_id'); - // 获取冻结中积分 - $memberIds = array_column($result['list'], 'member_id'); - $freezeWhere = [ - ['member_id', 'in', $memberIds], - ['status', '=', 0], - ]; - $freezeField = 'member_id,sum(get_integral) as total_get_integral'; - $freeze = model('commission_legumes_log')->getList($freezeWhere, $freezeField, '', 'a', [], 'member_id'); - $freeze = array_column($freeze, 'total_get_integral', 'member_id'); - foreach ($result['list'] as &$singleInfo) { - // 总冻结积分 - $singleInfo['total_freeze_integral'] = $freeze[$singleInfo['member_id']] ?? 0; - // 可使用积分 - $reduce = (float)sprintf("%.2f", $singleInfo['total_freeze_integral'] + $singleInfo['total_use_integral']);// 冻结 + 已使用积分 - $singleInfo['surplus_use_integral'] = (float)sprintf("%.2f", $singleInfo['total_get_integral'] - $reduce); - } - - return $result; - } - - /** - * Common: 获取单个用户持有信息 - * Author: wu-hui - * Time: 2024/05/09 16:06 - * @param $memberId - * @return array|mixed - */ - public function getMemberHoldInfo($memberId) - { - $result = $this->getHoldListData(1, ['member_id' => $memberId]); - $info = $result['list'] ?? []; - - return $info[0] ?? []; - } - - - /** - * Common: 获取全平台用户持有总积分信息 - * Author: wu-hui - * Time: 2024/05/29 11:40 - * @param $memberId - * @return array - */ - public function getAllSiteHoldInfo($memberId) - { - $memberId = (new Member())->getAllMemberIds($memberId); - // 根据用户id 获取全部相关持有信息 - $list = $this->getAllSiteHoldAllList(1, $memberId, true); - return [ - 'total_order_money' => sprintf("%.2f", array_sum(array_column($list, 'total_order_money'))), - 'total_get_legumes' => sprintf("%.2f", array_sum(array_column($list, 'total_get_legumes'))), - 'total_refund_order_money' => sprintf("%.2f", array_sum(array_column($list, 'total_refund_order_money'))), - 'total_refund_get_legumes' => sprintf("%.2f", array_sum(array_column($list, 'total_refund_get_legumes'))), - 'total_get_integral' => sprintf("%.2f", array_sum(array_column($list, 'total_get_integral'))), - 'total_use_integral' => sprintf("%.2f", array_sum(array_column($list, 'total_use_integral'))), - 'total_freeze_integral' => sprintf("%.2f", array_sum(array_column($list, 'total_freeze_integral'))), - 'surplus_use_integral' => sprintf("%.2f", array_sum(array_column($list, 'surplus_use_integral'))) - ]; - } - - /** - * Common: 获取全平台用户持有积分信息列表(递归获取全部列表) - * Author: wu-hui - * Time: 2024/05/29 11:34 - * @param $page - * @param $memberId - * @param false $isGetAll - * @param array $allList - * @return array - */ - public function getAllSiteHoldAllList($page, $memberId, $isGetAll = false, $allList = []) - { - // 获取信息 - $result = $this->getHoldListData($page, ['member_id' => $memberId]); - $pageCount = $result['page_count'] ?? 1; - $allList = array_merge($allList, $result['list']); - // 判断:是否递归查询全部 - if ($pageCount > $page && $isGetAll) { - return $this->getAllSiteHoldAllList(++$page, $memberId, true, $allList); - } - // 返回列表信息 - return $allList; - } - - - /** - * Common: 豆豆计算 - 计算昨天产生的豆豆总数 - * Author: wu-hui - * Time: 2024/05/08 18:13 - */ - public function computeYesterdayLegumes() - { - // 获取总平台配置信息 - $config = (new Setting())->getConfig(); - $legumesPrice = (new Setting())->getLegumesPrice(); - // 获取周期时间 - [$startTime, $endTime] = getTimeStamp('yesterday');// 天 - Db::startTrans(); - try { - // 判断:当前时间周期是否已经结算 - $maxTime = model('commission_legumes')->getMax([], 'end_time'); - if ($endTime <= $maxTime) throw new Exception('当前周期积分抽成已结算!'); -// [$startTime,$endTime] = getTimeStamp('today');// todo:调试信息 -// $startTime = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); -// $endTime = mktime(0, 0, 0, date('m'), date('d'), date('Y')); - // 获取周期内积分抽成信息 - $integralInfo = $this->getIntegralInfo($startTime, $endTime); - if ((float)$integralInfo['reality_money'] <= 0) throw new Exception('周期内无积分抽成信息'); - // 计算豆豆数量 豆豆数量 = 积分抽成金额(昨日总金额) * 0.2 / 豆豆当前价格 - $legumesNum = (float)sprintf("%.4f", (float)$integralInfo['reality_money'] * 0.2 / $legumesPrice); // 今日豆豆数量 - // 计算豆豆价格 下次豆豆价格 = 积分抽成金额(全平台总金额) ➗ 文创豆数量(全平台总数量) - $allIntegralInfo = $this->getIntegralInfo(); - $allLegumes = model('commission_legumes')->getSum([], 'legumes_num'); - $tomorrowLegumesPrice = sprintf("%.4f", $allIntegralInfo['reality_money'] / ($allLegumes + $legumesNum)); - // 记录 - $recordId = model('commission_legumes')->add([ - 'total_integral_money' => $integralInfo['total_money'], - 'refund_money' => $integralInfo['refund_money'], - 'reality_money' => $integralInfo['reality_money'], - 'legumes_price' => $legumesPrice, - 'legumes_num' => $legumesNum, - 'tomorrow_legumes_price' => $tomorrowLegumesPrice, - 'start_time' => $startTime, - 'end_time' => $endTime, - ]); - // 修改豆豆实时价格 - (new Setting())->setLegumesPrice(0, $tomorrowLegumesPrice); - // 触发事件 开始给每个消费用户分豆豆 - Queue::push(AllocationLegumesJob::class, [ - 'legumes_id' => $recordId - ]); - Db::commit(); - } catch (Exception $e) { - Db::rollback(); - $data = [ - 'start' => date("Y-m-d H:i:s", $startTime), - 'end' => date("Y-m-d H:i:s", $endTime), - 'msg' => $e->getMessage() - ]; - trace($data, '计算昨天产生的豆豆总数 - 错误'); - } - } - - /** - * Common: 豆豆计算 - 获取时间段内总积分抽成金额 - * Author: wu-hui - * Time: 2024/05/08 17:50 - * @param int $startTime - * @param int $endTime - * @return array - */ - public function getIntegralInfo(int $startTime = 0, int $endTime = 0): array - { - $where = []; - if ($startTime > 0 && $endTime > 0) { - $where[] = ['create_time', 'between', [date("Y-m-d H:i:s", $startTime), date("Y-m-d H:i:s", $endTime)]]; - } - // 总佣金 - $info['total_money'] = (float)model('commission_record')->getSum($where, 'integral_money'); - // 获取退款金额 - $info['refund_money'] = (float)model('commission_record')->getValue($where, 'sum((integral_money * refund_ratio / 100)) as refund_money'); - // 实际金额 - $info['reality_money'] = (float)sprintf("%.3f", (float)$info['total_money'] - (float)$info['refund_money']); - - return $info; - } - - - /** - * Common: 查询需要使用的分配信息 尽可能仅查询需要使用的信息 - * Author: wu-hui - * Time: 2024/05/11 9:45 - * @param int $memberId - * @param float $useLegumesIntegral - * @param int $page - * @return array|mixed - */ - public function getUseList(int $memberId, float $useLegumesIntegral, int $limit = 10) - { - $where = [ - ['status', '=', 1], - // [ 'member_id', '=', $memberId], - ['', 'exp', Db::raw('get_integral > use_integral')] - ]; - // 多平台同用户积分兼容 - $memberId = (new Member())->getAllMemberIds($memberId); - if (is_array($memberId)) $where[] = ['member_id', 'in', $memberId]; - else $where[] = ['member_id', '=', $memberId]; - - // 查询 - $field = 'id,member_id,get_integral,use_integral,(get_integral - use_integral) as surplus_integral'; - $result = model('commission_legumes_log')->pageList($where, $field, 'id ASC', 1, $limit); - $list = $result['list'] ?? []; - $pageCount = $result['page_count'] ?? 1; - // 判断:总页数 大于当前页 判断是否需要递归 - if ($pageCount > 1) { - $totalSurplusIntegral = array_sum(array_column($list, 'surplus_integral')); - if ($useLegumesIntegral > $totalSurplusIntegral) { - $limit += 10; - return $this->getUseList($memberId, $useLegumesIntegral, $limit); - } - } - - return $list; - } - - /** - * Common: 查询已使用积分的分配信息 尽可能查询需要的信息 - * Author: wu-hui - * Time: 2024/05/13 16:19 - * @param int $memberId - * @param float $maxIntegral - * @param int $limit - * @return array|mixed - */ - public function getUsedList(int $memberId, float $maxIntegral, int $limit = 10) - { - $where = [ - ['status', '=', 1], - // [ 'member_id', '=', $memberId], - ['use_integral', '>', 0], - ]; - // 多平台同用户积分兼容 - $memberId = (new Member())->getAllMemberIds($memberId); - if (is_array($memberId)) $where[] = ['member_id', 'in', $memberId]; - else $where[] = ['member_id', '=', $memberId]; - // 查询 - $result = model('commission_legumes_log')->pageList($where, 'id,get_integral,use_integral', 'id DESC', 1, $limit); - $list = $result['list'] ?? []; - $pageCount = $result['page_count'] ?? 1; - if ($pageCount > 1) { - $totalSurplusIntegral = array_sum(array_column($list, 'use_integral')); - if ($maxIntegral > $totalSurplusIntegral) { - $limit += 10; - return $this->getUseList($memberId, $maxIntegral, $limit); - } - } - - return $list; - } - - - /** - * Common: 获取统计信息 - * Author: wu-hui - * Time: 2024/05/11 15:09 - * @param array $params - * @return array - */ - public function getStatistics(array $params) - { - // 获取当前用户可用豆豆积分 - $legumes = (new Legumes())->getAllSiteHoldInfo((int)$params['member_id']); - // 获取统计信息 - $data = [ - 'integral_upper_limit' => $this->getModel($params)->sum('order_money'),// 积分释放上限(总) - 'get_legumes' => $this->getModel($params)->sum('get_legumes'),// 总获得豆豆 - 'refund_get_legumes' => $this->getModel($params)->sum('refund_get_legumes'),// 退款减少豆豆 - 'get_integral' => $this->getModel($params)->sum('get_integral'),// 获得积分 - 'freeze_integral' => $this->getModel($params)->where('status', 0)->sum('get_integral'),// 冻结中积分 - 'used_integral' => $legumes['surplus_use_integral'] ?? 0,// 可用积分 - 'use_integral' => $this->getModel($params)->sum('use_integral'),// 已使用积分 - ]; - // 未释放积分 = 积分释放上限 - 已获得积分 - $data['not_integral'] = (float)sprintf("%.4f", $data['integral_upper_limit'] - $data['get_integral']); - // 实际获得豆豆 - $data['reality_get_legumes'] = (float)sprintf("%.4f", $data['get_legumes'] - $data['refund_get_legumes']); - - return $data; - } - - /** - * Common: 查询model(统计查询使用) - * Author: wu-hui - * Time: 2024/05/11 15:00 - * @param $params - * @return Db - */ - public function getModel($params) - { - return Db::name('commission_legumes_log') - ->when((int)$params['member_id'] > 0, function ($query) use ($params) { - $memberId = (new Member())->getAllMemberIds((int)$params['member_id']); - if (is_array($memberId)) $query->whereIn('member_id', $memberId); - else $query->where('member_id', $memberId); - }) - ->when(isset($params['status']) && $params['status'] !== '', function ($query) use ($params) { - $query->where('status', $params['status']); - }) - ->whereIn('status', [0, 1]); - } - - -} diff --git a/addon/commission/model/Partner.php b/addon/commission/model/Partner.php deleted file mode 100644 index 5a2acbd..0000000 --- a/addon/commission/model/Partner.php +++ /dev/null @@ -1,286 +0,0 @@ -adminSiteId) $params['site_id'] = $siteId; - // 生成查询条件 - $where = []; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['a.site_id','=',$params['site_id']]; - // 关联查询 - $join = [ - [ 'site s', 's.site_id = a.site_id', 'left' ] - ]; - $field = [ - 'a.*', - 's.site_name', - 's.contacts_name', - ]; - $result = model('commission_partner_cycle')->pageList($where, $field,'a.id DESC',$page,PAGE_LIST_ROWS,'a',$join); - $result['is_admin'] = $siteId == $this->adminSiteId; - - return $this->success($result); - } - /** - * Common: 获取合伙人佣金分红记录 - * Author: wu-hui - * Time: 2024/05/09 10:53 - * @param $page - * @param $params - * @return array - */ - public function getLogPageList($page, $params){ - // 生成查询条件 - $where = []; - if(isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['a.member_id','=',$params['member_id']]; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['a.site_id','=',$params['site_id']]; - if(isset($params['cycle_id']) && $params['cycle_id'] !== '') $where[] = ['a.cycle_id','=',$params['cycle_id']]; - // 关联查询 - $join = [ - [ 'member m', 'm.member_id = a.member_id', 'left' ], - ]; - $field = [ - 'a.*', - 'm.nickname', - 'm.username', - 'm.headimg', - ]; - $result = model('commission_partner')->pageList($where,$field,'id DESC',$page,PAGE_LIST_ROWS, 'a', $join); - - return $this->success($result); - } - - - /** - * Common: 合伙人佣金结算 - 开始 - * Author: wu-hui - * Time: 2024/05/08 16:23 - */ - public function settlementInit(){ - Db::startTrans(); - try{ - // 获取总平台配置信息 - $config = (new Setting())->getConfig(); - // 获取周期时间 0=天;1=周;2=月 - if($config['partner_cycle'] == 1) [$startTime,$endTime] = getTimeStamp('last_week');// 周 - else if($config['partner_cycle'] == 2) [$startTime,$endTime] = getTimeStamp('last_month');// 月 - else [$startTime,$endTime] = getTimeStamp('yesterday');// 天 - - - // [$startTime,$endTime] = getTimeStamp('today');// TODO:调试使用... - - - // 获取全部子平台 然后循环处理 - $insertData = [];// 明细记录 - $cycleIds = [];// 周期ids - $siteList = model('site')->getList([],'site_id,site_name'); - foreach($siteList as $siteInfo){ - // 获取子平台配置信息 - $subConfig = (new Setting())->getConfig((int)$siteInfo['site_id']); - // 判断:是否允许执行 - $isRunResult = $this->settlementIsRun($subConfig, $siteInfo); - if((int)$isRunResult['code'] != 0){ - // trace([ - // 'msg' => $isRunResult['message'], - // 'site_id' => (int)$siteInfo['site_id'], - // ], '子平台循环处理 - 是否允许执行 - 跳出'); - continue; - } - // 获取分红金额信息 并且判断是否大于0 - $moneyInfo = $this->getTotalMoney($siteInfo, $startTime, $endTime); - if((float)$moneyInfo['reality_money'] <= 0){ - // trace([ - // 'site_id' => (int)$siteInfo['site_id'], - // 'money_info' => $moneyInfo - // ], '子平台循环处理 - 实际分红金额为0'); - model('commission_record')->update(['partner_status' =>1],[ - [ 'create_time', 'between', [ date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime) ] ], - ['partner_status','=', 0], - ['site_id','=', $siteInfo['site_id']], - ]); - continue; - } - // 获取用户权重值信息 - $userList = $this->getHoldList($endTime, $siteInfo); - $totalWeightValue = (float)array_sum($userList);// 总权重值 - if($totalWeightValue <= 0) { - trace([ - 'site_id' => (int)$siteInfo['site_id'], - 'totalWeightValue' => $totalWeightValue - ], '子平台循环处理 - 总权重值为0'); - model('commission_record')->update(['partner_status' =>2],[ - [ 'create_time', 'between', [ date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime) ] ], - ['partner_status','=', 0], - ['site_id','=', $siteInfo['site_id']], - ]); - continue; - } - // 记录周期分红信息 - $cycleId = model('commission_partner_cycle')->add([ - 'site_id' => (int)$siteInfo['site_id'], - 'total_commission' => $moneyInfo['total_money'], - 'refund_money' => $moneyInfo['refund_money'], - 'reality_money' => $moneyInfo['reality_money'], - 'total_weight_value' => $totalWeightValue, - 'total_people' => count($userList), - 'start_time' => $startTime, - 'end_time' => $endTime, - ]); - $cycleIds[] = $cycleId; - // 循环处理所有用户 - foreach($userList as $memberId => $weightValue){ - // 添加贡献分享分红信息记录 这里必须进行100的偏移计算 - $radio = (float)sprintf("%.2f",($weightValue / $totalWeightValue) * 100);// 佣金比例 - $money = (float)sprintf("%.2f",($moneyInfo['reality_money'] * $radio) / 100);// 实际获得佣金 - if($money > 0){ - $insertData[] = [ - 'site_id' => (int)$siteInfo['site_id'], - 'member_id' => $memberId, - 'cycle_id' => $cycleId, - 'money' => $money, - 'hold_contribution' => $totalWeightValue, - 'total_contribution' => $weightValue, - 'proportion' => $radio, - ]; - } - } - model('commission_record')->update(['partner_status' =>1],[ - ['create_time', 'between', [ date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime) ] ], - ['partner_status','=', 0], - ['site_id','=', $siteInfo['site_id']], - ]); - } - // 记录分红信息 并且开始结算 - if(count($insertData) > 0){ - model('commission_partner')->addList($insertData); - // 合伙人佣金结算 - Queue::push(PartnerSettlementJob::class,[ - 'cycle_ids' => $cycleIds - ]); - } - - Db::commit(); - }catch(Exception $e){ - Db::rollback(); - - trace($e->getMessage(), '合伙人佣金结算 - 错误'); - } - } - /** - * Common: 合伙人佣金结算 - 判断是否继续允许;获取分佣金额 - * Author: wu-hui - * Time: 2024/05/08 14:56 - * @param $subConfig - * @param $siteInfo - * @return array|void - */ - private function settlementIsRun($subConfig, $siteInfo){ - // 判断:是否开启 - if($subConfig['switch'] != 1) return $this->error('','未开启平台抽成'); - // 下一个周期结束时间获取 - $upCycleEndTime = model('commission_partner_cycle')->getMax(['site_id'=>$siteInfo['site_id']], 'end_time'); - if($subConfig['partner_cycle'] == 1) { - // 周 获取下一周开始时间 - $monday = strtotime('Monday this week', $upCycleEndTime); - $lastRunTime = strtotime(date("Y-m-d 00:00:00",$monday)." +1 week"); - } - else if($subConfig['partner_cycle'] == 2) { - // 月 获取下一月开始时间 - $lastRunTime = strtotime(date("Y-m-1 00:00:00",$upCycleEndTime)." +1 month"); - } - else{ - // 天 获取下一天开始时间 - $lastRunTime = strtotime(date("Y-m-d 00:00:00",$upCycleEndTime)." +1 day"); - } - // 判断:时间上是否允许继续执行(上一个周期结束时间存在 & 当前时间小于下一个周期结束时间 禁止继续执行) - if((int)$upCycleEndTime > 0 && time() < $lastRunTime) { - $msg = "执行时间错误(上一个周期结束时间".date('Y-m-d H:i:s',$upCycleEndTime).",下一个周期结束时间".date('Y-m-d H:i:s',$lastRunTime).")"; - return $this->error('',$msg); - } - - return $this->success('允许执行'); - } - /** - * Common: 合伙人佣金结算 - 获取指定平台时间段内的总佣金信息 - * Author: wu-hui - * Time: 2024/05/08 15:47 - * @param $siteInfo - * @param $startTime - * @param $endTime - * @return array - */ - public function getTotalMoney($siteInfo, $startTime, $endTime){ - // 总佣金 - $moneyInfo['total_money'] = (float)model('commission_record')->getSum([ - [ 'create_time', 'between', [ date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime) ] ], - ['partner_status','=', 0], - ['site_id','=', $siteInfo['site_id']], - ], 'partner_money'); - // 获取退款金额 - $refundMoneyInfo = model('commission_record')->getInfo([ - [ 'create_time', 'between', [ date("Y-m-d H:i:s",$startTime), date("Y-m-d H:i:s",$endTime) ] ], - ['partner_status','=', 0], - ['site_id','=', $siteInfo['site_id']], - ],'sum((partner_money * refund_ratio / 100)) as refund_money'); - $moneyInfo['refund_money'] = sprintf("%.2f",$refundMoneyInfo['refund_money'] ?? 0); - // 实际金额 - $moneyInfo['reality_money'] = (float)sprintf("%.3f",(float)$moneyInfo['total_money'] - (float)$moneyInfo['refund_money']); - - return $moneyInfo; - } - /** - * Common: 合伙人佣金结算 - 获取截止结束时用户持有权重值 - * Author: wu-hui - * Time: 2024/05/08 16:08 - * @param $endTime - * @param $siteInfo - * @return array - */ - private function getHoldList($endTime, $siteInfo){ - $idList = model('commission_weight_value_log')->getList([ - [ 'create_time', '<=', date("Y-m-d H:i:s",$endTime)], - ['site_id','=', $siteInfo['site_id']], - ],'max(id) as max_id,CONCAT(member_id,"_", level_id) as group_key','','a',[],'group_key'); - $ids = array_column($idList,'max_id'); - $list = model('commission_weight_value_log')->getList([ - ['id', 'in', $ids], - ],'member_id,sum(change_after) as change_after','','a',[],'member_id'); - - return array_column($list,'change_after','member_id'); - } - - -} \ No newline at end of file diff --git a/addon/commission/model/Setting.php b/addon/commission/model/Setting.php deleted file mode 100644 index 374a810..0000000 --- a/addon/commission/model/Setting.php +++ /dev/null @@ -1,196 +0,0 @@ - '0',// 是否开启平台抽成 - 'is_alone' => '0',// 是否独立设置 总平台无该设置项 - 'integral_rate' => '0',// 积分抽成比例 - 'operations_rate' => '0',// 运营抽成比例 - 'partner_rate' => '0',// 合伙人分佣比例 - 'partner_cycle' => '0',// 合伙人分佣周期 0=每天,1=每周,2=每月 - 'merchants_rate' => '0',// 招商员分佣比例 - 'promoter_rate' => '0',// 推广员分佣比例 - ]; - - - /** - * Common: 编辑配置 - 总平台、店铺 - * Author: wu-hui - * Time: 2024/04/29 14:51 - * @param int $siteId - * @param array $data - * @param int $is_use - * @return array - */ - public function setConfig(int $siteId = 0,array $data = [],int $is_use = 1){ - $setWhere = [ - ['site_id','=', $siteId > 0 ? $siteId : $this->adminSiteId], - ['app_module','=','shop'], - ['config_key','=','commission_setting'] - ]; - - return (new Config())->setConfig($data, '平台抽成设置', $is_use, $setWhere); - } - /** - * Common: 获取配置 - 总平台、店铺 - * Author: wu-hui - * Time: 2024/04/29 14:51 - * @param int $siteId - * @return array|string[] - */ - public function getConfig(int $siteId = 0){ - $setWhere = [ - ['site_id','=', $siteId > 0 ? $siteId : $this->adminSiteId], - ['app_module','=','shop'], - ['config_key','=','commission_setting'] - ]; - $res = (new Config())->getConfig($setWhere); - $value = $res['data'] ? $res['data']['value'] : []; - $config = array_merge($this->defaultConfig, $value); - // 判断:当前获取设置 是否为总平台设置 - $config['is_admin'] = $siteId == $this->adminSiteId; - - return $config; - } - - - /** - * Common: 编辑配置 - 商品 - * Author: wu-hui - * Time: 2024/05/02 10:15 - * @param int $goodsId - * @param array $data - */ - public function setGoodConfig(int $goodsId,array $data){ - // 判断:当前商品是否已经存在设置 - $set = model('goods_commission')->getInfo(['goods_id'=>$goodsId]); - $set = $set ?? []; - $updateData = [ - 'switch' => $data['switch'] ?? 0, - 'is_alone' => $data['is_alone'] ?? 0, - 'commission_type' => $data['commission_type'] ?? 0, - 'integral_rate' => $data['integral_rate'] ?? 0, - 'operations_rate' => $data['operations_rate'] ?? 0, - 'partner_rate' => $data['partner_rate'] ?? 0, - 'merchants_rate' => $data['merchants_rate'] ?? 0, - 'promoter_rate' => $data['promoter_rate'] ?? 0, - ]; - if($set){ - model('goods_commission')->update($updateData,['goods_id'=>$goodsId]); - }else{ - $updateData['goods_id'] = $goodsId; - $updateData['site_id'] = $data['site_id']; - model('goods_commission')->add($updateData); - } - } - /** - * Common: 获取配置 - 商品 - * Author: wu-hui - * Time: 2024/04/30 17:49 - * @param int $goodsId - * @return array|string[] - */ - public function getGoodConfig(int $goodsId){ - $set = model('goods_commission')->getInfo(['goods_id'=>$goodsId]); - $set = $set ?? []; - $defaultConfig = $this->defaultConfig; - $defaultConfig['switch'] = $set['switch'] ?? 1;//商品默认开启 - $defaultConfig['commission_type'] = $set['commission_type'] ?? 0;//抽成类型:0=比例,1=固定金额 - - return array_merge($defaultConfig, $set); - } - /** - * Common: 获取最终设置 - * Author: wu-hui - * Time: 2024/05/03 11:49 - * @param int $siteId - * @param int $goodsId - * @return array|string[] - */ - public function getFinalSet(int $siteId,int $goodsId = 0){ - // ---获取总平台设置 - $adminSet = $this->getConfig(); - if($siteId == $this->adminSiteId) return $adminSet; - // ---获取子平台(店铺)设置 - $shopSet = $this->getConfig((int)$siteId); - // 店铺关闭抽成 || (店铺开启抽成,但是为独立设置)=使用店铺设置;店铺开启抽成 并且不为独立设置=总平台统一设置 - if($shopSet['switch'] == 0 || ($shopSet['switch'] == 1 && $shopSet['is_alone'] == 1)) $shopFinal = $shopSet; - else $shopFinal = $adminSet; - // 处理店铺不可修改项 - $shopFinal['partner_cycle'] = $adminSet['partner_cycle']; - $goodFinal['operations_rate'] = $adminSet['operations_rate']; - $shopFinal['is_alone'] = $shopSet['is_alone']; - // 判断:是否仅获取店铺级 最终设置;是则返回店铺级最终设置;否则继续判断商品级 - if($goodsId <= 0) return $shopFinal; - // ---获取商品设置 - $goodSet = (array)$this->getGoodConfig($goodsId); - if(empty($goodSet)) return $shopFinal; - // 商品关闭抽成 || (商品开启抽成,但是为独立设置)=使用商品设置;商品开启抽成 并且不为独立设置=店铺最终设置 - if($goodSet['switch'] == 0 || ($goodSet['switch'] == 1 && $goodSet['is_alone'] == 1)) $goodFinal = $goodSet; - else $goodFinal = $shopFinal; - // 设置补齐 - $goodFinal['partner_cycle'] = $adminSet['partner_cycle']; - $goodFinal['operations_rate'] = $shopFinal['operations_rate'];// todo 运营抽成目前商品不可独立设置 - $goodFinal['is_alone'] = $goodSet['is_alone']; - - return $goodFinal; - } - - - /** - * Common: 豆豆价格 - 设置 - * Author: wu-hui - * Time: 2024/05/08 17:39 - * @param int $siteId - * @param float $legumesPrice - * @return array - */ - public function setLegumesPrice(int $siteId = 0,float $legumesPrice = 0.5){ - $setWhere = [ - ['site_id','=', $siteId > 0 ? $siteId : $this->adminSiteId], - ['app_module','=','shop'], - ['config_key','=','legumes_price'] - ]; - - return (new Config())->setConfig(['legumes_price' => $legumesPrice], '豆豆价格', 1, $setWhere); - } - /** - * Common: 豆豆价格 - 获取 - * Author: wu-hui - * Time: 2024/05/08 17:37 - * @param int $siteId - * @return float|mixed - */ - public function getLegumesPrice(int $siteId = 0){ - $setWhere = [ - ['site_id','=', $siteId > 0 ? $siteId : $this->adminSiteId], - ['app_module','=','shop'], - ['config_key','=','legumes_price'] - ]; - $res = (new Config())->getConfig($setWhere); - $value = $res['data'] ? $res['data']['value'] : []; - - return $value['legumes_price'] ?? 0.5; - } - - - - - - -} diff --git a/addon/commission/model/WeightValue.php b/addon/commission/model/WeightValue.php deleted file mode 100644 index a7021a0..0000000 --- a/addon/commission/model/WeightValue.php +++ /dev/null @@ -1,145 +0,0 @@ -adminSiteId) $params['site_id'] = $siteId; - // 生成查询条件 - $where = []; - if(isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['a.member_id','=',$params['member_id']]; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['a.site_id','=',$params['site_id']]; - // 关联查询 - $join = [ - [ 'member m', 'm.member_id = a.member_id', 'left' ], - [ 'site s', 's.site_id = a.site_id', 'left' ], - [ 'fenxiao_level fl', 'fl.level_id = a.level_id', 'left' ] - ]; - $field = [ - 'a.*', - 'm.nickname', - 'm.username', - 'm.headimg', - 's.site_name', - 's.contacts_name', - 'fl.level_name', - 'fl.level_num', - ]; - $result = model('commission_weight_value')->pageList($where,$field,'a.id DESC',$page,PAGE_LIST_ROWS,'a',$join); - $result['is_admin'] = $siteId == $this->adminSiteId; - - return $this->success($result); - } - /** - * Common: 获取用户权重值变更记录明细 - * Author: wu-hui - * Time: 2024/05/04 16:07 - * @param $page - * @param $params - * @return array - */ - public function getLogPageList($page, $params){ - // 生成查询条件 - $where = []; - if(isset($params['member_id']) && $params['member_id'] !== '') $where[] = ['member_id','=',$params['member_id']]; - if(isset($params['site_id']) && $params['site_id'] !== '') $where[] = ['site_id','=',$params['site_id']]; - if(isset($params['level_id']) && $params['level_id'] !== '') $where[] = ['level_id','=',$params['level_id']]; - // 关联查询 - $result = model('commission_weight_value_log')->pageList($where,true,'id DESC',$page,PAGE_LIST_ROWS); - - return $this->success($result); - } - - - /** - * Common: 根据用户ID 获取所有有效上级持有权重值信息 - * Author: wu-hui - * Time: 2024/05/04 13:45 - * @param int $memberId - * @param int $siteId - * @param array $userHoldList - * @return array - */ - public function getUserHoldList(int $memberId,int $siteId,array $userHoldList = []){ - // 获取用户所有上级 - if(count($userHoldList) <= 0){ - // 获取全部上级 - $fenXiaoId = model('fenxiao')->getValue(['member_id'=>$memberId],'fenxiao_id'); - $allSuperiorList = (new Fenxiao())->getAllSuperior($fenXiaoId); - unset($allSuperiorList[$memberId]);// 删除本人 - if(count($allSuperiorList) <= 0) return [];// 不存在上级 - // 循环处理 仅小区业绩消费才会获得权重值奖励 - $userHoldList = [];// 符合条件的用户 - $currentFenXiaoId = $fenXiaoId; - foreach($allSuperiorList as $userInfo){ - // 判断:当前用户是否为上级的大区业绩的线 - if(!(new Fenxiao())->isBigAreaPart((int)$currentFenXiaoId,(int)$userInfo['fenxiao_id'])){ - $userHoldList[] = $userInfo; - } - $currentFenXiaoId = $userInfo['fenxiao_id']; - } - } - // 获取持有信息 - $where = [ - ['site_id', '=', $siteId], - ['member_id', 'in', array_column($userHoldList,'member_id')] - ]; - $field = 'id,site_id,member_id,level_id,quantity,CONCAT(member_id, "_", level_id) AS only_key'; - $holdList = model('commission_weight_value')->getList($where,$field); - // 判断:是否有不存在的用户持有信息 有则先添加 - $holdList = array_column($holdList,null,'only_key'); - $onlyKeyList = array_column($holdList,'only_key'); - $insertData = []; - // 判断:是否存在持有信息 不存在添加 - $currentLevelList = []; - foreach($userHoldList as $userItem){ - $onlyKey = $userItem['member_id'].'_'.$userItem['level_id']; - if(!in_array($onlyKey,$onlyKeyList)){ - // 不存在 需要添加 - $defaultData = [ - 'site_id' => $siteId, - 'member_id' => $userItem['member_id'], - 'level_id' => $userItem['level_id'], - 'quantity' => 0, - ]; - $insertData[] = $defaultData; - } - else{ - $currentLevelList[] = $holdList[$onlyKey]; - } - } - // 存在新增加内容 增加然后再次执行 - if(count($insertData) > 0) { - model('commission_weight_value')->addList($insertData); - - return $this->getUserHoldList($memberId,$siteId,$userHoldList); - } - - return $currentLevelList; - } - - - -} \ No newline at end of file diff --git a/addon/commission/shop/controller/Index.php b/addon/commission/shop/controller/Index.php deleted file mode 100644 index 11ae1a6..0000000 --- a/addon/commission/shop/controller/Index.php +++ /dev/null @@ -1,245 +0,0 @@ -isAjax()) { - // 参数获取 - $page = input('page', 1); - $params = [ - 'member_id' => input('member_id', ''), - 'site_id' => input('site_id', ''), - 'order_no' => input('order_no', ''), - 'goods_id' => input('goods_id', ''), - ]; - return (new CommissionRecord())->getPageList($page, $params, $this->site_id); - } - $this->forthMenu(); - return $this->fetch("index/index"); - } - /** - * Common: 获取抽成记录统计信息 - * Author: wu-hui - * Time: 2024/05/13 9:48 - * @return array - */ - public function recordStatistics(){ - $params = [ - 'member_id' => input('member_id', ''), - 'site_id' => input('site_id', ''), - 'order_no' => input('order_no', ''), - 'goods_id' => input('goods_id', ''), - ]; - $data = (new CommissionRecord())->getStatistics($params, $this->site_id); - - return success(0, 'success', [ - ['className' => 'el-icon-coin','count' => $data['total_real_goods_money'],'name' => '订单总金额'], - ['className' => 'el-icon-coin','count' => $data['total_integral_money'],'name' => '积分抽成总金额'], - ['className' => 'el-icon-coin','count' => $data['total_operations_money'],'name' => '运营抽成总金额'], - ['className' => 'el-icon-coin','count' => $data['total_partner_money'],'name' => '合伙人抽成总金额'], - ['className' => 'el-icon-coin','count' => $data['total_merchants_money'],'name' => '招商员抽成总金额'], - ['className' => 'el-icon-coin','count' => $data['total_promoter_money'],'name' => '推广员抽成总金额'], - ]); - } - /** - * Common: 权重值 - 持有列表 - * Author: wu-hui - * Time: 2024/05/04 16:01 - * @return array|mixed - */ - public function weightValue(){ - if (request()->isAjax()) { - // 参数获取 - $page = input('page', 1); - $params = [ - 'member_id' => input('member_id', '') - ]; - return (new WeightValue())->getPageList($page, $params, $this->site_id); - } - - $this->forthMenu(); - return $this->fetch("index/weight_value"); - } - /** - * Common: 权重值 - 变更记录明细 - * Author: wu-hui - * Time: 2024/05/04 16:07 - * @return array - */ - public function weightValueLog(){ - $page = input('page', 1); - $params = [ - 'site_id' => input('site_id',''), - 'member_id' => input('member_id',''), - 'level_id' => input('level_id',''), - ]; - - return (new WeightValue())->getLogPageList($page, $params); - } - /** - * Common: 合伙人佣金 - 周期记录 - * Author: wu-hui - * Time: 2024/05/09 10:54 - * @return array|mixed - */ - public function partner(){ - if (request()->isAjax()) { - // 参数获取 - $page = input('page', 1); - $params = []; - return (new Partner())->getPageList($page, $params, $this->site_id); - } - - $this->forthMenu(); - return $this->fetch("index/partner"); - } - /** - * Common: 合伙人佣金 - 分红记录 - * Author: wu-hui - * Time: 2024/05/09 10:54 - * @return array - */ - public function partnerLog(){ - $page = input('page', 1); - $params = [ - 'site_id' => input('site_id',''), - 'member_id' => input('member_id',''), - 'cycle_id' => input('cycle_id',''), - ]; - - return (new Partner())->getLogPageList($page, $params); - } - /** - * Common: 获取豆豆积分 - * Author: wu-hui - * Time: 2024/05/13 10:30 - * @return array - */ - public function getLegumesStatistics(){ - // 获取实时豆豆价格 - $legumesPrice = (new Setting())->getLegumesPrice(); - $params = [ - 'legumes_id' => input('legumes_id',''), - 'member_id' => input('member_id',''), - 'status' => input('status',''), - ]; - $data = (new Legumes())->getTotalStatistics($params); - - return success(0, 'success', [ - ['className' => 'el-icon-coin','count' => $legumesPrice,'name' => '当前豆豆价格'], - ['className' => 'el-icon-coin','count' => $data['total_get_legumes'],'name' => '已分配豆豆'], - ['className' => 'el-icon-coin','count' => $data['total_order_money'],'name' => '订单总金额(积分上限)'], - ['className' => 'el-icon-coin','count' => $data['total_get_integral'],'name' => '已产生积分'], - ['className' => 'el-icon-coin','count' => $data['total_use_integral'],'name' => '已使用积分'], - ['className' => 'el-icon-coin','count' => $data['total_freeze_integral'],'name' => '冻结中积分'], - ]); - } - /** - * Common: 豆豆积分 - 周期记录 - * Author: wu-hui - * Time: 2024/05/09 11:55 - * @return array|mixed - */ - public function legumes(){ - if (request()->isAjax()) { - // 参数获取 - $page = input('page', 1); - $params = []; - return (new Legumes())->getCycleList($page, $params); - } - - $this->forthMenu(); - return $this->fetch("index/legumes"); - } - /** - * Common: 豆豆积分 - 分配记录 - * Author: wu-hui - * Time: 2024/05/09 11:58 - * @return array - */ - public function legumesLog(){ - $page = input('page', 1); - $params = [ - 'legumes_id' => input('legumes_id',''), - 'member_id' => input('member_id',''), - 'status' => input('status',''), - ]; - - return (new Legumes())->getLegumesLogList($page, $params); - } - /** - * Common: 豆豆积分 - 持有记录 - * Author: wu-hui - * Time: 2024/05/09 13:46 - * @return array - */ - public function legumesHoldList(){ - $page = input('page', 1); - $params = [ - 'member_id' => input('member_id',''), - ]; - - return (new Legumes())->getHoldList($page, $params); - } - // 佣金流水列表 - public function accountList(){ - if (request()->isAjax()) { - // 参数获取 - $params = [ - 'member_id' => input('member_id',''), - 'account_type' => input('account_type',''), - 'status' => input('status',''), - 'page' => input('page',1), - 'page_size' => input('limit',10), - ]; - - return (new Account())->accountListV2($params); - } - $this->forthMenu(); - return $this->fetch("index/account_list"); - } - - - /** - * Common: 基本设置 - * Author: wu-hui - * Time: 2024/04/29 16:36 - * @return array|mixed - */ - public function set(){ - if (request()->isAjax()) { - // 参数获取 - $info = input('set',[]); - (new Setting())->setConfig((int)$this->site_id, (array)$info); - - return success(0, '修改成功'); - } - else { - $set = (new Setting())->getConfig((int)$this->site_id); - $adminSet = (new Setting())->getConfig(); - $this->forthMenu(); - - return $this->fetch("index/set",[ - 'set' => json_encode($set, JSON_UNESCAPED_UNICODE), - 'admin_set' => json_encode($adminSet, JSON_UNESCAPED_UNICODE), - ]); - } - } -} diff --git a/addon/commission/shop/controller/Test.php b/addon/commission/shop/controller/Test.php deleted file mode 100644 index bf47438..0000000 --- a/addon/commission/shop/controller/Test.php +++ /dev/null @@ -1,1609 +0,0 @@ -computeYesterdayLegumes(); - -// -// var_dump($res);die; - // $orderIds = [257,259,262,267,271]; - // foreach($orderIds as $orderId){ - // $this->createRecord($orderId); - // } -// $this->createRecord(354); -// die; - - // $this->GiveWeightValueTest(); - // $this->MerchantsSettlement(); - // $this->PromoterSettlement(); - // (new Partner())->settlementInit(); - // $this->PartnerSettlement(); - // (new Legumes())->computeYesterdayLegumes(); - // $this->AllocationLegumes(); - // $this->ComputeIntegral(); - // $this->settlementMoney(); - // $this->useLegumesIntegral(); - // $this->orderRefundFinish(); - - - /*$params = array ( - 'order_id' => 280, - 'order_no' => '20240717100137001', - 'site_id' => 5, - 'site_name' => '张先生', - 'website_id' => 0, - 'order_name' => '0.1元买单', - 'order_from' => 'cashier', - 'order_from_name' => '收银台', - 'order_type' => 5, - 'order_type_name' => '收银订单', - 'order_promotion_type' => 0, - 'order_promotion_name' => '', - 'promotion_id' => 0, - 'out_trade_no' => '17211816855317612629', - 'out_trade_no_2' => '', - 'delivery_code' => '', - 'order_status' => 10, - 'order_status_name' => '已完成', - 'order_status_action' => '{"status":10,"name":"已完成","is_allow_refund":1,"icon":"public\\/resource\\/order\\/order-icon-received.png","action":[],"member_action":[],"color":""}', - 'pay_status' => 1, - 'delivery_status' => 0, - 'refund_status' => 0, - 'pay_type' => 'wechatpay', - 'pay_type_name' => '微信支付', - 'delivery_type' => '0', - 'delivery_type_name' => '', - 'member_id' => 37, - 'name' => '', - 'mobile' => '', - 'telephone' => '', - 'province_id' => 0, - 'city_id' => 0, - 'district_id' => 0, - 'community_id' => 0, - 'address' => '', - 'full_address' => '', - 'longitude' => '', - 'latitude' => '', - 'buyer_ip' => '', - 'buyer_ask_delivery_time' => '', - 'buyer_message' => '', - 'goods_money' => '0.10', - 'delivery_money' => '0.00', - 'promotion_money' => '0.00', - 'coupon_id' => 0, - 'coupon_money' => '0.00', - 'invoice_money' => '0.00', - 'order_money' => '0.10', - 'adjust_money' => '0.00', - 'balance_money' => '0.00', - 'pay_money' => '0.10', - 'create_time' => 1721181685, - 'pay_time' => 1721181693, - 'delivery_time' => 0, - 'sign_time' => 0, - 'finish_time' => 1721181693, - 'close_time' => 0, - 'is_lock' => 0, - 'is_evaluate' => 0, - 'is_delete' => 0, - 'is_enable_refund' => 1, - 'remark' => '', - 'goods_num' => '1.000', - 'delivery_store_id' => 0, - 'delivery_status_name' => '', - 'is_settlement' => 0, - 'store_settlement_id' => 0, - 'delivery_store_name' => '', - 'promotion_type' => '', - 'promotion_type_name' => '', - 'promotion_status_name' => '', - 'delivery_store_info' => NULL, - 'virtual_code' => '', - 'evaluate_status' => 0, - 'evaluate_status_name' => '', - 'refund_money' => '0.00', - 'commission' => '0.00', - 'is_invoice' => 0, - 'invoice_type' => 1, - 'invoice_title' => '', - 'taxpayer_number' => '', - 'invoice_rate' => '0.00', - 'invoice_content' => '', - 'invoice_delivery_money' => '0.00', - 'invoice_full_address' => '', - 'is_tax_invoice' => 0, - 'invoice_email' => '', - 'invoice_title_type' => 0, - 'is_fenxiao' => 1, - 'point_money' => '0.00', - 'member_card_money' => '0.00', - 'member_card_order' => 0, - 'invoice_status' => 0, - 'invoice_remark' => NULL, - 'invoice_code' => '', - 'invoice_image' => '', - 'invoice_time' => 0, - 'predict_delivery_time' => 0, - 'is_video_number' => 0, - 'is_sync_order' => 0, - 'is_deduction' => 0, - 'sync_msg' => '', - 'close_cause' => '', - 'cashier_order_type' => 'goods', - 'cashier_sell_time' => 0, - 'cashier_operator_id' => 0, - 'cashier_operator_name' => '', - 'balance' => '0.00', - 'total_balance' => '0.00', - 'store_id' => 8, - 'reduction' => '0.00', - 'round_money' => '0', - 'order_scene' => 'cashier', - 'store_commission_rate' => '0.00', - 'store_commission' => '0.00', - 'cl_id' => 0, - 'cl_name' => '', - 'is_community_settlement' => 0, - 'arrive_time' => 0, - 'delivery_id' => 0, - 'commission_rate' => '0.00', - 'delivery_commission' => '0.00', - 'delivery_community_id' => 0, - 'delivery_community' => '', - 'delivery_community_info' => NULL, - 'legumes_integral_use' => '0.00', - 'legumes_integral_money' => '0.00', - 'legumes_integral_community' => 0.0, - );*/ - // (new Weapp($params['site_id']))->getRidInfo(); - // debug("结果"); - // (new Weapp($params['site_id']))->authSendGoods($params); - // 积分收入结算到店铺 调试 - // (new ShopAccount())->orderIntegralSettlement(336); - // $this->handleOperations(); -// $this->verificationLegumesPrice(); - // 修改豆豆实时价格 - // (new Setting())->setLegumesPrice(0, 7.3859); - -// $this->afreshComputeLegumes(); -// $this->afreshAllocationLegumes(); - - - -// $this->settlementAccount(); - - - - debug("调试中...". date("Y-m-d H:i:s")); - } - // 调试 - 支付成功生成抽成记录 - private function createRecord($orderId){ - -// $orderId = (int)$data['order_id']; -// $orderId=''; - $adminSet = (new Setting())->getConfig(); - if($adminSet['switch'] != 1) throw new Exception('总平台未开启平台抽成'); - // 当前订单是否已经处理 - $isHas = (int)model('commission_record')->getValue([ - ['order_id', '=', $orderId] - ],'id'); -// if($isHas > 0) throw new Exception('当前订单已经处理'); - // 获取订单商品信息 - $field = 'order_goods_id,order_id,site_id,member_id,goods_id,store_id,num,(real_goods_money + legumes_integral_use) as use_money'; - $orderGoodsList = model('order_goods')->getList(['order_id'=>$orderId],$field); - // 循环处理 - $insertData = []; - foreach($orderGoodsList as $orderGoodsInfo){ - $useMoney = $orderGoodsInfo['use_money'] ?? 0; - if($useMoney <= 0) continue;// 当前订单商品有效金额为0 - // 设置获取 - $set = (new Setting())->getFinalSet((int)$orderGoodsInfo['site_id'],(int)$orderGoodsInfo['goods_id']); - if($set['switch'] != 1) continue;// 当前商品不参与平台抽成 - $integralRate = (float)$set['integral_rate'] ?? 0; - $operationsRate = (float)$set['operations_rate'] ?? 0; - $partnerRate = (float)$set['partner_rate'] ?? 0; - $merchantsRate = (float)$set['merchants_rate'] ?? 0; - $promoterRate = (float)$set['promoter_rate'] ?? 0; - // 根据抽成计算类型生成记录信息 - $commissionType = $set['commission_type'] ?? 0; - $insertData[] = [ - 'member_id' => $orderGoodsInfo['member_id'], - 'site_id' => $orderGoodsInfo['site_id'], - 'store_id' => $orderGoodsInfo['store_id'], - 'order_id' => $orderGoodsInfo['order_id'], - 'order_goods_id' => $orderGoodsInfo['order_goods_id'], - 'goods_id' => $orderGoodsInfo['goods_id'], - 'real_goods_money' => $useMoney, - // 根据计算类型获取值 抽成类型:0=比例,1=固定金额 - 'integral_rate' => $commissionType == 1 ? -1 : $integralRate, - 'integral_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $integralRate) : sprintf("%.3f",$useMoney * $integralRate / 100), - 'operations_rate' => $operationsRate, - 'operations_money' => sprintf("%.3f",$useMoney * $operationsRate / 100), - 'partner_rate' => $commissionType == 1 ? -1 : $partnerRate, - 'partner_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $partnerRate) : sprintf("%.3f",$useMoney * $partnerRate / 100), - 'merchants_rate' => $commissionType == 1 ? -1 : $merchantsRate, - 'merchants_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $merchantsRate) : sprintf("%.3f",$useMoney * $merchantsRate / 100), - 'promoter_rate' => $commissionType == 1 ? -1 : $promoterRate, - 'promoter_money' => $commissionType == 1 ? sprintf("%.3f",$orderGoodsInfo['num'] * $promoterRate) : sprintf("%.3f",$useMoney * $promoterRate / 100), - ]; - } - var_dump($insertData); - // - // - // - // -// if(count($insertData) > 0){ -//// model('commission_record')->addList($insertData); -// // 支付成功 - 抽成记录生成后 - 招商员佣金结算 -// Queue::push(MerchantsSettlementJob::class,[ -// 'order_id' => (int)$orderId -// ]); -// // 支付成功 - 抽成记录生成后 - 推广员佣金结算 -// Queue::push(PromoterSettlementJob::class,[ -// 'order_id' => (int)$orderId, -// ]); -// } - } - // 调试 - 支付成功赠送权重值 - private function GiveWeightValueTest(){ - // $data = [ - // 'member_id' => 21, - // 'order_id' => 224, - // 'site_id' => 2, - // ]; - // try{ - // // 获取当前用户 所有有效上级的 权重值持有信息 - // $userHoldList = (new WeightValue())->getUserHoldList((int)$data['member_id'], (int)$data['site_id']); - // - // debug($userHoldList); - // // 获取当前订单中所有商品 - // $orderGoodsField = 'order_goods_id,order_id,goods_id,(real_goods_money + point_money) as use_money'; - // $orderGoodsList = model('order_goods')->getList([['order_id','=', $data['order_id']]], $orderGoodsField); - // $updateData = []; - // $insertLogData = []; - // foreach($userHoldList as $userInfo){ - // foreach($orderGoodsList as $goodsInfo){ - // // 判断:当前用户是否存在修改记录中 不存在添加修改信息 - // if(empty($updateData[$userInfo['id']])){ - // $updateData[$userInfo['id']] = [ - // 'id' => $userInfo['id'], - // 'quantity' => $userInfo['quantity'], - // ]; - // } - // // 持有数量增加 - // $changeFront = (float)$updateData[$userInfo['id']]['quantity']; - // $updateData[$userInfo['id']]['quantity'] = (float)sprintf("%.2f",(float)$goodsInfo['use_money'] + $changeFront); - // // 记录变更记录 - // $insertLogData[] = [ - // 'site_id' => (int)$data['site_id'], - // 'member_id' => $userInfo['member_id'], - // 'level_id' => $userInfo['level_id'], - // 'goods_id' => $goodsInfo['goods_id'], - // 'order_id' => $goodsInfo['order_id'], - // 'order_goods_id' => $goodsInfo['order_goods_id'], - // 'change_type' => 1, - // 'change_quantity' => $goodsInfo['use_money'], - // 'change_front' => $changeFront, - // 'change_after' => (float)$updateData[$userInfo['id']]['quantity'], - // 'remark' => '下线购买商品赠送', - // ]; - // } - // } - // - // - // debug($insertLogData); - // // 数据结果处理 - // if(count($insertLogData) > 0){ - // // 修改 - // // $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_weight_value', 'pk' => 'id'])); - // // $goodsSkuModel->saveAll($updateData); - // // model('commission_weight_value_log')->addList($insertLogData); - // } - // } - // catch(\Exception $e){ - // $data['error_msg'] = $e->getMessage(); - // debug(['失败:调试中...'=>$data]); - // } - } - // 调试 - 招商员佣金结算 - private function MerchantsSettlement(){ - $orderId = (int)48; - // 当前订单 - // $where = [ - // // ['order_id', '=', $orderId], - // ['merchants_status', '=', 0], - // ]; - // $field = 'a.id,a.site_id,a.store_id,a.order_id,a.merchants_money,s.merchants_member_id,s.store_name'; - // $join = [ - // ['store s', 's.store_id = a.store_id', 'LEFT'], // 关联客服 - // ]; - // $list = model('commission_record')->getList($where,$field,'','a',$join); - // // 循环处理 - // $updateData = []; - // $insertData = []; - // foreach($list as $recordInfo){ - // // 根据是否存在招商员 进行对应的处理 - // if((int)$recordInfo['merchants_member_id'] > 0){ - // // 存在招商员 招商员佣金结算 - // $insertData[] = [ - // 'site_id' => $recordInfo['site_id'], - // 'member_id' => $recordInfo['merchants_member_id'], - // 'join_id' => $recordInfo['id'], - // 'account_type' => 'merchants', - // 'account_type_name' => '招商员佣金', - // 'account_data' => $recordInfo['merchants_money'], - // 'remark' => $recordInfo['store_name'] . '的订单收入', - // ]; - // // 修改信息 - // $updateData[] =[ - // 'id' => $recordInfo['id'], - // 'merchants_status' => 1, - // ]; - // } - // else{ - // // 不存在招商员 - // $updateData[] =[ - // 'id' => $recordInfo['id'], - // 'merchants_status' => 2, - // ]; - // } - // } - // // 数据结果处理 - // if(count($insertData) > 0) model('commission_account')->addList($insertData); - // if(count($updateData) > 0){ - // $updateModel = (new NewBaseModel(['table_name' => 'commission_record', 'pk' => 'id'])); - // $updateModel->saveAll($updateData); - // } - - - - // debug([ - // '修改内容'=> $updateData, - // '循环列表' => $list, - // '$insertData' => $insertData, - // '$updateData' => $updateData, - // - // ]); - } - // 调试 - 推广员佣金结算 - private function PromoterSettlement(){ - // $orderId = (int)48; - // // 当前订单 - // $where = [ - // // ['order_id', '=', $orderId], - // ['promoter_status', '=', 0], - // ]; - // $join = [ - // ['member m', 'a.member_id = m.member_id', 'LEFT'], - // ['fenxiao fx', 'm.fenxiao_id = fx.fenxiao_id', 'LEFT'], - // ]; - // $field = 'a.id,a.site_id,a.member_id,a.promoter_money,m.is_fenxiao,m.nickname,fx.member_id as fenxiao_member_id,fx.parent'; - // $list = model('commission_record')->getList($where,$field,'','a', $join); - // // 循环处理 - // $updateData = []; - // $insertData = []; - // foreach($list as $recordInfo){ - // // 判断:当前用户是否为分销 获取对应的上级分销商用户id - // if($recordInfo['is_fenxiao'] == 1){ - // // 当前用户是分销商 使用parent查询上级用户id - // $parentMemberId = model('fenxiao')->getValue(['fenxiao_id'=>$recordInfo['parent']], 'member_id'); - // }else{ - // // 当前用户不是分销商 直接为fenxiao_member_id - // $parentMemberId = $recordInfo['fenxiao_member_id']; - // } - // // 判断:是否存在上级 - // if((int)$parentMemberId > 0){ - // // 存在上级 - // $insertData[] = [ - // 'site_id' => $recordInfo['site_id'], - // 'member_id' => $parentMemberId, - // 'join_id' => $recordInfo['id'], - // 'account_type' => 'promoter', - // 'account_type_name' => '推广员佣金', - // 'account_data' => $recordInfo['promoter_money'], - // 'remark' => $recordInfo['nickname'] . '的推广佣金', - // ]; - // // 修改信息 - // $updateData[] =[ - // 'id' => $recordInfo['id'], - // 'promoter_status' => 1, - // ]; - // }else{ - // // 不存在上级 - // $updateData[] =[ - // 'id' => $recordInfo['id'], - // 'promoter_status' => 2, - // ]; - // } - // } - // // 数据结果处理 - // if(count($insertData) > 0) model('commission_account')->addList($insertData); - // if(count($updateData) > 0){ - // $updateModel = (new NewBaseModel(['table_name' => 'commission_record', 'pk' => 'id'])); - // $updateModel->saveAll($updateData); - // } - // debug([ - // '修改内容'=> $updateData, - // '循环列表' => $list, - // '$insertData' => $insertData, - // '$updateData' => $updateData, - // - // ]); - } - // 调试 - 合伙人佣金结算 - private function PartnerSettlement(){ - // $data = [ - // 'cycle_ids' => [ - // 0 => 5, - // ], - // ]; - // - // $cycleIds = $data['cycle_ids'] ?? []; - // if(count($cycleIds) <= 0) throw new Exception('无周期记录信息!'); - // // 获取周期结算信息 - // $cycleList = model('commission_partner_cycle')->getList([ - // ['id', 'in', $cycleIds] - // ],'id,start_time,end_time'); - // $cycleList = array_column($cycleList, null, 'id'); - // // 获取结算记录信息 - // $list = model('commission_partner')->getList([ - // ['cycle_id', 'in', $cycleIds], - // ['is_settlement', '=', 0], - // ],'id,member_id,cycle_id,money,site_id'); - // if(count($list) > 0){ - // $insertData = []; - // foreach($list as $singleInfo){ - // $cycleInfo = $cycleList[$singleInfo['cycle_id']] ?? []; - // $timePeriod = date("Y-m-d H:i:s",$cycleInfo['start_time']) . ' ~ ' . date("Y-m-d H:i:s",$cycleInfo['end_time']); - // $insertData[] = [ - // 'site_id' => $singleInfo['site_id'], - // 'member_id' => $singleInfo['member_id'], - // 'join_id' => $singleInfo['id'], - // 'account_type' => 'partner', - // 'account_type_name' => '合伙人佣金', - // 'account_data' => $singleInfo['money'], - // 'remark' => $timePeriod . "权重值收入", - // ]; - // } - // // 记录信息 - // if(count($insertData) > 0) model('commission_account')->addList($insertData); - // // 修改结算状态 - // $ids = array_column($list,'id'); - // model('commission_partner')->update([ 'is_settlement' => 1],[ - // ['id', 'in', $ids] - // ]); - // } - - debug("结束"); - } - // 调试 - 豆豆分配 - private function AllocationLegumes(){ - $data = [ - 'legumes_id' => 29, - ]; - - // 获取周期信息 - $legumesId = $data['legumes_id']; - $cycleLegumes = model('commission_legumes')->getInfo(['id' => $legumesId]); - if(!$cycleLegumes) throw new Exception('信息不存在'); - // if((int)$cycleLegumes['status'] != 0) throw new Exception('当前豆豆已分配!'); - // 获取时间段所有消费用户 - $where = [ - [ 'a.pay_time', 'between', [ $cycleLegumes['start_time'], $cycleLegumes['end_time'] ] ],// 指定时间段内 - [ 'og.refund_status', 'in', [0, 3] ],// 订单商品未退款 - [ 'a.order_status', 'in', [1, 3, 4, 10, 11, 12] ],//待发货、已发货、已收货、已完成、待使用、已使用 - ]; - $join = [ - [ 'order_goods og', 'og.order_id = a.order_id', 'right' ], - ]; - $field = 'og.order_id,og.order_goods_id,og.member_id,a.order_status,(sum(og.real_goods_money) + sum(og.legumes_integral_money)) as sum_money'; - $orderList = model('order')->getList($where,$field,'','a',$join,'og.order_goods_id'); - - debug($where); - $totalMoney = array_sum(array_column($orderList,'sum_money')); - // debug([$totalMoney,implode(',', array_column($orderList,'order_id')),$orderList]); - // 获取平台抽成信息 - $orderGoodsIds = array_column($orderList,'order_goods_id'); - $commissionRecord = model('commission_record')->getList([ - ['order_goods_id','in',$orderGoodsIds], - ],'order_goods_id,order_id,member_id,integral_money as platform_commission_money'); - $totalPlatformCommission = array_sum(array_column($commissionRecord,'platform_commission_money')); - $commissionRecord = array_column($commissionRecord,null,'order_goods_id'); - // 循环处理 - $insertData = []; - foreach($orderList as $orderInfo){ - // 获取平台抽成信息 - $platformCommissionInfo = $commissionRecord[$orderInfo['order_goods_id']] ?? []; - if($platformCommissionInfo){ - // 计算订单金额占比 必须进行100的偏移计算 - $rate = (float)sprintf("%.3f",$platformCommissionInfo['platform_commission_money'] / $totalPlatformCommission * 100); - $getLegumes = sprintf("%.3f",$cycleLegumes['legumes_num'] * $rate / 100); - // 信息记录 - $insertData[] = [ - 'member_id' => $orderInfo['member_id'], - 'legumes_id' => $legumesId, - 'order_id' => $orderInfo['order_id'], - 'order_goods_id' => $orderInfo['order_goods_id'], - 'cycle_total_legumes' => $cycleLegumes['legumes_num'], - 'total_sales_money' => $totalMoney, - 'order_money' => $orderInfo['sum_money'], - 'order_money_rate' => $rate, - 'get_legumes' => $getLegumes, - 'status' => in_array((int)$orderInfo['order_status'],[10,12]) ? 1 : 0, - ]; - } - } - // - debug($insertData); - // // 添加数据 - // if(count($insertData) > 0) model('commission_legumes_log')->addList($insertData); - // // 修改豆豆周期分配状态 - // model('commission_legumes')->update(['status' => 1],[ - // ['id', '=', $legumesId] - // ]); - // // 触发全平台豆豆转积分操作 - // Queue::push(ComputeIntegralJob::class); - } - // 调试 - 全平台豆豆转积分 - private function ComputeIntegral($data = []){ - // // 判断:当前data不为数组时 强制为数组 - // if(!is_array($data)) $data = []; - // // 并且开启处理 - // $page = $data['page'] ?? 1; - // $ids = $data['ids'] ?? []; - // $limit = 1000; - // $legumesPrice = (new Setting())->getLegumesPrice(); - // // 获取当前页数据 有效记录、已获取积分低于订单金额 - // $where = [ - // ['status', 'in', [0,1]] - // ]; - // if(count($ids) > 0) $where[] = ['id', 'in', $ids]; - // else $where[] = ['', 'exp', Db::raw('get_integral < order_money')]; - // $field = 'id,(order_money - refund_order_money) as order_money,(get_legumes - refund_get_legumes) as get_legumes,get_integral,member_id'; - // $result = model('commission_legumes_log')->pageList($where,$field,'',$page,$limit); - // $count = $result['count'] ?? 0; - // $list = $result['list'] ?? []; - // if(count($list) <= 0) throw new \Exception('无处理数据!'); - // // 循环处理 - // $updateData = []; - // $insertData = []; - // foreach($list as $item){ - // // 计算最新本订单商品 总释放积分;总释放积分不能超过订单金额 - // $getIntegral = (float)sprintf("%.2f",$item['get_legumes'] * $legumesPrice); - // $resultGetIntegral = $getIntegral >= $item['order_money'] ? $item['order_money'] : $getIntegral; - // // 修改信息记录 - // $updateData[] = [ - // 'id' => $item['id'], - // 'get_integral' => $resultGetIntegral - // ]; - // // 增加释放记录 - // $insertData[] = [ - // 'member_id' => $item['member_id'], - // 'legumes_log_id' => $item['id'], - // 'change_front' => $item['get_integral'], - // 'change_quantity' => (float)sprintf("%.2f",$resultGetIntegral - $item['get_integral']), - // 'change_after' => $resultGetIntegral, - // ]; - // } - // - // // 修改 - // $newBaseModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - // $newBaseModel->saveAll($updateData); - // // 增加记录 - // if(count($insertData) > 0) model('commission_legumes_release_log')->addList($insertData); - // // 判断:是否存在下一页 - // $currentLimit = $page * $limit; - // if($currentLimit < $count){ - // $data['page'] = $page + 1; - // Queue::push(ComputeIntegralJob::class,$data); - // } - } - // 调试 - 流水结算到账 - private function settlementMoney(){ - - $data = [ - // 'account_type' => 'partner', - // - 'order_id' => 355, - 'account_type' => 'merchants_promoter', - ]; - - - Db::startTrans(); - try{ - // trace($data, '平台抽成 - 流水结算到账 - 开始'); - - // 根据结算流水类型 获取对应条件 - $where = [ - ['status', '=', 0] - ]; - if($data['account_type'] == 'partner') { - // 合伙人佣金 - $where[] = ['account_type', '=', 'partner']; - } - else if($data['account_type'] == 'merchants_promoter') { - // 推广员佣金、招商员佣金 - $where[] = ['account_type', 'in', ['promoter', 'merchants']]; - // 仅结算指定订单相关 - $joinIds = model('commission_record')->getColumn([ - ['order_id', '=', $data['order_id']] - ],'id'); - $where[] = ['join_id', 'in', $joinIds]; - } - // 流水列表 - // $list = model('commission_account')->getList($where,'id,sum(account_data) as total_account_data,member_id','','a',[],'member_id'); - $list = Db::name('commission_account') - ->field('id,sum(account_data) as total_account_data,member_id') - ->where('status', 0) - ->when($data['account_type'] == 'partner',function($query){ - $query->where('account_type', 'partner'); - },function($query) use ($data){ - // 仅结算指定订单相关 - $joinIds = model('commission_record')->getColumn([ - ['order_id', '=', $data['order_id']] - ],'id'); - $query->whereIn('account_type', ['promoter', 'merchants']) - ->whereIn('join_id', $joinIds); - }) - ->group('member_id') - ->select() - ->toArray(); - - - - - debug($list); - - // trace($list, '平台抽成 - 流水结算到账 - 流水列表'); - // 获取用户已经持有信息 - $memberIds = array_column($list, 'member_id'); - $userList = Db::name('member') - ->field('commission_money,member_id') - ->whereIn('member_id', $memberIds) - ->select() - ->toArray(); - $userList = array_column($userList, null, 'member_id'); - // 循环流水列表 结算信息 - foreach($list as $singleInfo){ - $userList[$singleInfo['member_id']]['commission_money'] += $singleInfo['total_account_data']; - } - // 修改 - // $newBaseModel = (new NewBaseModel(['table_name' => 'member', 'pk' => 'member_id'])); - // $userList = array_values($userList); - // $newBaseModel->saveAll($userList); - // // 已结算 - // model('commission_account')->update(['status'=>1],[ - // ['id', 'in', array_column($list, 'id')] - // ]); - - - - // trace($userList, '平台抽成 - 流水结算到账 - 处理完成'); - Db::commit(); - - debug([ - '用户信息修改列表' => $userList, - '处理流水列表' => $list - ]); - } - catch(\Exception $e){ - Db::rollback(); - $data['error_msg'] = $e->getMessage(); - - debug($data); - // trace($data, '平台抽成 - 流水结算到账 - 失败'); - } - } - // 调试 - 订单支付成功 使用豆豆积分 - private function useLegumesIntegral(){ - // $data = [ - // 'order_id' => 66 - // ]; - // - // - // - // // 获取订单信息 - // $orderInfo = model('order')->getInfo([ - // ['order_id','=', $data['order_id']], - // ['legumes_integral_use','>', 0] - // ],'order_id,site_id,member_id,legumes_integral_use,legumes_integral_money'); - // if(!$orderInfo) throw new \Exception('信息不存在!'); - // $useLegumesIntegral = (float)$orderInfo['legumes_integral_use']; - // // 查询需要使用的分配记录 - // $useLegumesLogList = (new Legumes())->getUseList((int)$orderInfo['member_id'],(float)$orderInfo['legumes_integral_use']); - // // 循环处理 - // $updateData = []; - // foreach($useLegumesLogList as $logInfo){ - // $useIntegral = $useLegumesIntegral >= $logInfo['surplus_integral'] ? (float)$logInfo['surplus_integral'] : (float)$useLegumesIntegral; - // $useLegumesIntegral = (float)sprintf("%.2f",$useLegumesIntegral - $useIntegral); - // $updateData[] = [ - // 'id' => $logInfo['id'], - // 'use_integral' => (float)sprintf("%.2f",$logInfo['use_integral'] + $useIntegral) - // ]; - // if($useLegumesIntegral <= 0) break; - // } - // // 修改成功信息 - // if($updateData){ - // // 修改豆豆积分使用信息 - // $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - // $goodsSkuModel->saveAll($updateData); - // // 添加用户账单信息变更记录 - // $mark = '购买商品使用'.$orderInfo['legumes_integral_use'].'积分抵扣'.floatval($orderInfo['legumes_integral_money']).'元'; - // model('commission_account')->add([ - // 'site_id' => $orderInfo['site_id'], - // 'member_id' => $orderInfo['member_id'], - // 'join_id' => $orderInfo['order_id'], - // 'account_type' => 'use_legumes_integral', - // 'account_type_name' => '积分使用', - // 'account_data' => '-'.$orderInfo['legumes_integral_use'], - // 'status' => 1, - // 'remark' => $mark, - // ]); - // } - - - - - } - // 退款处理 - private function orderRefundFinish(){ -/* $data = array ( - 'order_goods_id' => 235, - 'order_id' => 218, - 'order_no' => '20240513135030313361', - 'site_id' => 2, - 'member_id' => 21, - 'goods_id' => 3, - 'sku_id' => 4, - 'sku_name' => '削笔机削笔器 ', - 'sku_image' => 'https://aidian-1251027355.cos.ap-chengdu.myqcloud.com/upload/2/common/images/20240425/20240425030636171402879621442.jpg', - 'sku_no' => '', - 'is_virtual' => 0, - 'goods_class' => '1', - 'goods_class_name' => '实物商品', - 'price' => '29.90', - 'cost_price' => '0.00', - 'num' => '5.000', - 'goods_money' => '149.50', - 'cost_money' => '0.00', - 'delivery_status' => 0, - 'delivery_status_name' => '未发货', - 'delivery_no' => '', - 'gift_flag' => 0, - 'refund_no' => '202405130151256359', - 'refund_status' => 3, - 'refund_status_name' => '维权结束', - 'refund_status_action' => '{"status":3,"name":"维权结束","action":[],"member_action":[]}', - 'refund_type' => 1, - 'refund_apply_money' => '100.00', - 'refund_reason' => '商家对订单进行了主动退款', - 'refund_real_money' => '100.00', - 'refund_delivery_name' => '', - 'refund_delivery_no' => '', - 'refund_time' => 1715579490, - 'refund_refuse_reason' => '', - 'refund_action_time' => 1715579485, - 'real_goods_money' => '148.88', - 'refund_remark' => '商家对订单进行了主动退款', - 'refund_delivery_remark' => '', - 'refund_address' => '', - 'is_refund_stock' => 0, - 'refund_money_type' => 1, - 'shop_active_refund' => 0, - 'shop_refund_remark' => '', - 'refund_mode' => 1, - 'promotion_money' => '0.00', - 'coupon_money' => '0.00', - 'adjust_money' => '0.00', - 'goods_name' => '削笔机削笔器', - 'sku_spec_format' => '', - 'is_fenxiao' => 1, - 'use_point' => 0, - 'point_money' => '0.00', - 'refund_delivery_money' => '0.00', - 'create_time' => 1715579430, - 'out_aftersale_id' => '202405131350303133611715579485235', - 'refund_address_id' => 0, - 'refund_pay_money' => '0.00', - 'store_id' => 2, - 'card_item_id' => 0, - 'card_promotion_money' => '0.00', - 'legumes_integral_use' => '1.10', - 'legumes_integral_money' => '0.62', - ); - Db::startTrans(); - try{ - if($data['refund_status_action']){ - // 判断:当前商品是否存在豆豆积分抵扣情况 - if((int)$data['legumes_integral_use'] <= 0) throw new Exception('商品不存在豆豆积分抵扣'); - //计算退款比例 单位:% - $refundRate = (float)sprintf("%.2f",(float)$data['refund_real_money'] / (float)$data['real_goods_money'] * 100); - // 退款成功 计算平台抽成相关退款内容 - $this->handleCommissionRecord($data['order_goods_id'], $refundRate); - // 退款成功 权重值相关处理 - $this->handleWeightValue($data['order_goods_id'], $refundRate); - // 招商员佣金 & 推广员佣金处理 - $this->HandleCommissionMoney($data['order_goods_id'], $refundRate); - // 合伙人佣金处理 - $this->HandlePartnerMoney($data['order_goods_id'], $refundRate); - // 积分和豆豆处理 - $this->HandleLegumes($data['order_goods_id'], $refundRate); - // 抵扣积分退回 - $this->HandleIntegral($data['order_goods_id'], $refundRate); - } - - Db::commit(); - }catch(Exception $e){ - Db::rollback(); - - debug('错误:' . $e->getMessage()); - }*/ - } - // 退款处理 - 平台抽成记录处理 - private function handleCommissionRecord($orderGoodsId, $refundRate){ - $hasRefundRatio = (float)model('commission_record')->getValue(['order_goods_id'=>$orderGoodsId],'refund_ratio'); - $updateData = [ - 'refund_ratio' => (float)sprintf("%.2f", $hasRefundRatio + $refundRate) - ]; - if($updateData['refund_ratio'] >= 100){ - $updateData['refund_ratio'] = 100; - $updateData['partner_status'] = 3; - $updateData['merchants_status'] = 3; - $updateData['promoter_status'] = 3; - } - model('commission_record')->update($updateData,[ - ['order_goods_id', '=', $orderGoodsId] - ]); - - - return true; - } - // 退款处理 - 权重值相关处理 - private function handleWeightValue($orderGoodsId, $refundRate){ - $weightValueLogList = model('commission_weight_value_log')->getList([ - ['order_goods_id', '=', $orderGoodsId], - ['change_type', '=', 1], - ['source', '=', 0], - ],'id,member_id,level_id,order_goods_id,change_quantity,goods_id,order_id'); - $insertLogData = []; - $updateData = []; - foreach($weightValueLogList as $weightValueLogInfo){ - // 获取用户持有信息 - $holdInfo = model('commission_weight_value')->getInfo([ - ['member_id', '=', $weightValueLogInfo['member_id']], - ['level_id', '=', $weightValueLogInfo['level_id']], - ]); - // 获取已经减少数量 - $reduced = model('commission_weight_value_log')->getSum([ - ['order_goods_id', '=', $weightValueLogInfo['order_goods_id']], - ['change_type', '=', 0], - ['source', '=', 1], - ['member_id', '=', $weightValueLogInfo['member_id']], - ], 'change_quantity'); - // 计算减少信息,总减少数量不能超过获取数量 - $reduce = (float)sprintf("%.2f",$weightValueLogInfo['change_quantity'] * $refundRate / 100); - $totalReduce = (float)sprintf("%.2f",$reduced * $reduce); - if($totalReduce > $weightValueLogInfo['change_quantity']) $reduce = (float)sprintf("%.2f",$weightValueLogInfo['change_quantity'] - $reduced); - $changeFront = $holdInfo->quantity; - $surplusQuantity = (float)sprintf("%.2f",$holdInfo['quantity'] - $reduce); - $updateData[] = [ - 'id' => $holdInfo['id'], - 'quantity' => $surplusQuantity - ]; - // 记录变更记录 - $insertLogData[] = [ - 'site_id' => $holdInfo['site_id'], - 'member_id' => $weightValueLogInfo['member_id'], - 'level_id' => $weightValueLogInfo['level_id'], - 'goods_id' => $weightValueLogInfo['goods_id'], - 'order_id' => $weightValueLogInfo['order_id'], - 'order_goods_id' => $weightValueLogInfo['order_goods_id'], - 'change_type' => 0, - 'change_quantity' => $reduce, - 'change_front' => $changeFront, - 'change_after' => (float)$surplusQuantity, - 'remark' => '商品退款,减少权重值', - 'source' => 1, - ]; - } - - if(count($insertLogData) > 0){ - model('commission_weight_value_log')->addList($insertLogData); - } - if(count($updateData) > 0){ - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_weight_value', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - } - - - return true; - } - // 退款处理 - 招商员佣金 & 推广员佣金处理 - private function HandleCommissionMoney($orderGoodsId, $refundRate){ - $where = [ - ['order_goods_id', '=', $orderGoodsId], - ['merchants_status', '=', 1], - ]; - $field = [ - 'a.id', - 'a.site_id', - 'a.store_id', - 'a.order_id', - 'a.order_goods_id', - 'a.merchants_money', - 's.merchants_member_id', - 's.store_name', - 'a.member_id', - 'a.promoter_money', - 'm.is_fenxiao', - 'm.nickname', - 'fx.member_id as fenxiao_member_id', - 'fx.parent' - ]; - $join = [ - ['store s', 's.store_id = a.store_id', 'LEFT'], // 关联客服 - ['member m', 'a.member_id = m.member_id', 'LEFT'], - ['fenxiao fx', 'm.fenxiao_id = fx.fenxiao_id', 'LEFT'], - ]; - $info = model('commission_record')->getInfo($where,$field,'a',$join); - if(!$info) return false; - // 处理招商员佣金 - if((int)$info['merchants_member_id'] > 0){ - // 获取冻结中佣金信息 - $reduce = (float)sprintf("%.3f",$info['merchants_money'] * $refundRate / 100);// 减少数量 - model('commission_account')->add([ - 'site_id' => $info['site_id'], - 'member_id' => $info['merchants_member_id'], - 'join_id' => $info['id'], - 'account_type' => 'merchants_refund', - 'account_type_name' => '招商员佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => '订单退款,减少收入', - 'status' => 2, - ]); - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $info['merchants_member_id']]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $info['merchants_member_id']], - ]); - } - // 处理推广员佣金 - if($info['is_fenxiao'] == 1) $parentMemberId = model('fenxiao')->getValue(['fenxiao_id'=>$info['parent']], 'member_id');// 当前用户是分销商 使用parent查询上级用户id - else $parentMemberId = $info['fenxiao_member_id'];// 当前用户不是分销商 直接为fenxiao_member_id - if($parentMemberId > 0){ - $reduce = (float)sprintf("%.3f",$info['promoter_money'] * $refundRate / 100);// 减少数量 - model('commission_account')->add([ - 'site_id' => $info['site_id'], - 'member_id' => $parentMemberId, - 'join_id' => $info['id'], - 'account_type' => 'promoter_refund', - 'account_type_name' => '推广员佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => '订单退款,减少收入', - 'status' => 2, - ]); - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $parentMemberId]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $parentMemberId], - ]); - } - - return true; - } - // 退款处理 - 合伙人佣金处理 - private function HandlePartnerMoney($orderGoodsId, $refundRate){ - $commissionRecord = model('commission_record')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'partner_status,create_time,partner_money'); - // 待结算-结算时处理,已结算-减少用户已获得佣金,2、3-无处理 - if($commissionRecord['partner_status'] == 1){ - // 获取:获取当前抽成结算的归属周期 - $createTime = strtotime($commissionRecord['create_time']); - $cycleInfo = model('commission_partner_cycle')->getInfo([ - ['start_time', '<', $createTime], - ['end_time', '>', $createTime], - ]); - if($cycleInfo){ - // 计算总退款的合伙人佣金 - $reduceCommissionMoney = (float)sprintf("%.3f",$commissionRecord['partner_money'] * $refundRate / 100);// 减少数量 - // 获取退款的用户列表 - $userList = model('commission_partner')->getList([ - ['cycle_id', '=', $cycleInfo['cycle_id']], - ],'id,site_id,member_id,money,proportion,cycle_id'); - $insertData = []; - foreach($userList as $partnerInfo){ - // 计算当前用户应扣除合伙人佣金 - $reduce = (float)sprintf("%.2f",$reduceCommissionMoney * $partnerInfo['proportion'] / 100); - // 记录账单 - $insertData = [ - 'site_id' => $partnerInfo['site_id'], - 'member_id' => $partnerInfo['member_id'], - 'join_id' => $partnerInfo['id'], - 'account_type' => 'partner_refund', - 'account_type_name' => '合伙人佣金退款', - 'account_data' => '-' . $reduce, - 'remark' => "订单退款,减少收入", - 'status' => 2, - ]; - $memberCommissionMoney = model('member')->getValue([['member_id', '=', $partnerInfo['member_id']]], 'commission_money'); - model('member')->update(['commission_money' => sprintf("%.2f", $memberCommissionMoney - $reduce)],[ - ['member_id', '=', $partnerInfo['member_id']], - ]); - } - // 记录账单变化信息 - if (count($insertData) > 0) model('commission_account')->addList($insertData); - } - } - - return true; - } - // 退款处理 - 积分和豆豆处理 - private function HandleLegumes($orderGoodsId, $refundRate){ - // 获取当前抽成信息 - $commissionRecord = model('commission_record')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'id,create_time'); - // 判断:当前抽成豆豆信息是否已经结算,未结算-无操作处理(结算时处理退款内容);已结算-处理退款相关内容 - $maxEndTime = model('commission_legumes')->getMax([],'end_time'); - $createTime = strtotime($commissionRecord['create_time']); - if($createTime < $maxEndTime){ - // 已结算 - 处理退款相关内容 - $legumesId = model('commission_legumes')->getValue([ - ['start_time', '<', $createTime], - ['end_time', '>', $createTime] - ], 'id'); - if($legumesId > 0){ - // 获取需要修改的信息列表 - $correlationList = model('commission_legumes_log')->getList([ - ['legumes_id', '=', $legumesId] - ], 'id,member_id,order_money,refund_order_money,get_legumes,refund_get_legumes,get_integral'); - // 循环处理 - $updateData = []; - foreach($correlationList as $correlationInfo){ - // 计算 退款金额 - $reduceOrderMoney = (float)sprintf("%.2f",$correlationInfo['order_money'] * $refundRate / 100); - $refundOrderMoney = (float)sprintf("%.3f", $correlationInfo['refund_order_money'] + $reduceOrderMoney); - if($refundOrderMoney > $correlationInfo['order_money']) $refundOrderMoney = $correlationInfo['order_money']; - // 计算 退款豆豆 - $reduceGetLegumes = (float)sprintf("%.2f",$correlationInfo['get_legumes'] * $refundRate / 100); - $refundGetLegumes = (float)sprintf("%.3f", $correlationInfo['refund_get_legumes'] + $reduceGetLegumes); - if($refundGetLegumes > $correlationInfo['get_legumes']) $refundGetLegumes = $correlationInfo['get_legumes']; - // 记录修改信息 - $updateData[] = [ - 'id' => $correlationInfo['id'], - 'refund_order_money' => $refundOrderMoney, - 'refund_get_legumes' => $refundGetLegumes - ]; - } - - if(count($updateData) > 0) { - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - Queue::push(ComputeIntegralJob::class,[ - 'ids' => array_column($correlationList,'id') - ]); - } - } - } - - return true; - } - // 退款处理 - 抵扣积分退回 - private function HandleIntegral($orderGoodsId, $refundRate){ - // 获取订单商品信息 - $orderProductInfo = model('order_goods')->getInfo([ - ['order_goods_id', '=', $orderGoodsId] - ],'site_id,member_id,order_id,legumes_integral_use'); - $useLegumesIntegral = $orderProductInfo['legumes_integral_use'] ?? 0; - $memberId = $orderProductInfo['member_id'] ?? 0; - if($useLegumesIntegral > 0 && $memberId > 0){ - // 计算退回积分 - $returnIntegral = (float)sprintf("%.2f",$useLegumesIntegral * $refundRate / 100); - // 获取退回的记录列表 - $useLegumesLogList = (new Legumes())->getUsedList((int)$memberId,(float)$returnIntegral); - // 循环处理 - $returnComputeIntegral = $returnIntegral;// 计算用 退回积分 - $updateData = []; - foreach($useLegumesLogList as $logInfo){ - // 当前分配信息可退回积分 剩余可退回积分 - $reduce = $returnComputeIntegral < $logInfo['use_integral'] ? $returnComputeIntegral : $logInfo['use_integral']; - $returnComputeIntegral = (float)sprintf("%.2f",$returnComputeIntegral - $reduce); - $updateData[] = [ - 'id' => $logInfo['id'], - 'use_integral' => (float)sprintf("%.2f",$logInfo['use_integral'] - $reduce) - ]; - if($returnComputeIntegral <= 0) break; - } - if($updateData){ - // 修改 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - // 添加用户账单信息变更记录 - $mark = '订单退款 - 退回抵扣积分:'.$returnIntegral; - model('commission_account')->add([ - 'site_id' => $orderProductInfo['site_id'], - 'member_id' => $memberId, - 'join_id' => $orderProductInfo['order_id'], - 'account_type' => 'refund_legumes_integral', - 'account_type_name' => '积分退回', - 'account_data' => $returnIntegral, - 'status' => 2, - 'remark' => $mark, - ]); - } - } - - return true; - } - // 运营抽成处理 - 区分技术和平台 - private function handleOperations(){ - $list = model('commission_record')->getList([ - ['operations_money', '>', 0] - ],'id,operations_money'); - $updateData = []; - foreach($list as $item){ - $operationsMoney = (float)$item['operations_money'];// 运营抽成总金额 - $operationsTechnologyMoney = (float)sprintf("%.3f",$operationsMoney * 0.2);// 运营抽成 - 技术公司所得(20%) - $operationsPlatformMoney = (float)sprintf("%.3f",$operationsMoney - $operationsTechnologyMoney);// 运营抽成 - 平台所得(80%) - - $updateData[] = [ - 'id' => $item['id'], - 'operations_technology_money' => $operationsTechnologyMoney, - 'operations_platform_money' => $operationsPlatformMoney, - ]; - } - // debug($updateData); - if($updateData){ - // 修改 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_record', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - } - } - // 验证 - 每日豆豆价格是否正确 - private function verificationLegumesPrice(){ - $list = model('commission_legumes')->getList('','','id ASC'); - foreach($list as $item){ - echo "
"; - echo "
"; - echo "数据库存储数据
"; - echo "时间段:" . date("Y-m-d H:i:s", $item['start_time']) . ' ~ ' . date("Y-m-d H:i:s", $item['end_time']) . "
"; - echo date("Y-m-d H:i:s", $item['start_time'])."豆豆价格:" . $item['legumes_price'] . "
"; - echo date("Y-m-d H:i:s", $item['start_time'])."产生豆豆数量:" . $item['legumes_num'] . "
"; - echo date("Y-m-d H:i:s", $item['end_time'])."豆豆价格:" . $item['tomorrow_legumes_price'] . "
"; - echo "
"; - // 计算豆豆价格 豆豆价格 = 积分抽成金额(全平台总金额) ➗ 文创豆数量(全平台总数量) - echo "校验数据 重新根据抽成记录进行计算
"; - $total_money = (float)model('commission_record')->getSum([ - [ 'create_time', '<=', date("Y-m-d H:i:s", $item['start_time']) ] - ], 'integral_money');// 总佣金 - // 获取退款金额 - $refund_money = (float)model('commission_record')->getValue([ - [ 'create_time', '<=', date("Y-m-d H:i:s", $item['start_time']) ] - ],'sum((integral_money * refund_ratio / 100)) as refund_money'); - // 实际金额 - $reality_money = (float)sprintf("%.3f",(float)$total_money - (float)$refund_money); - // 以产生豆豆 - $allLegumes = model('commission_legumes')->getSum([ - [ 'start_time', '<=', $item['start_time'] ] - ],'legumes_num'); - - echo "截止".date("Y-m-d H:i:s", $item['start_time'])."
"; - echo date("Y-m-d H:i:s", $item['start_time'])."前全平台总积分抽成佣金:{$total_money}
"; - echo date("Y-m-d H:i:s", $item['start_time'])."前全平台总积分抽成佣金退款金额:{$refund_money}
"; - echo date("Y-m-d H:i:s", $item['start_time'])."前全平台实际有效总积分抽成佣金:{$reality_money}
"; - echo date("Y-m-d H:i:s", $item['start_time'])."前全平台已产生豆豆:{$allLegumes}
"; - if($total_money > 0) echo date("Y-m-d H:i:s", $item['start_time'])."豆豆价格:".sprintf("%.4f",$reality_money / $allLegumes)."
"; - else echo date("Y-m-d H:i:s", $item['start_time'])."豆豆价格:0.5
"; - echo "

"; - } - - - debug("结束"); - } - - - // 重新计算豆豆相关数据 - private function afreshComputeLegumes(){ - - $legumesModel = new Legumes(); - $list = model('commission_legumes')->getList([ - ['id', '>', 23] - ]); - $legumesPrice = 6.31;//0.5; - $allLegumes = model('commission_legumes')->getSum([ - ['id', '<=', 23] - ], 'legumes_num'); - $updateData = []; - - foreach($list as $legumes){ - // 获取周期内积分抽成信息 - $integralInfo = $legumesModel->getIntegralInfo($legumes['start_time'],$legumes['end_time']); - // if((float)$integralInfo['reality_money'] <= 0){ - // echo "ID:{$legumes['id']}无积分抽成信息"; - // continue; - // } - // 计算豆豆数量 豆豆数量 = 积分抽成金额(昨日总金额) * 0.2 / 豆豆当前价格 - $legumesNum = (float)sprintf("%.4f",(float)$integralInfo['reality_money'] * 0.2 / $legumesPrice); - // 计算豆豆价格 下次豆豆价格 = 积分抽成金额(全平台总金额) ➗ 文创豆数量(全平台总数量) - $allIntegralInfo = $legumesModel->getIntegralInfo(1704076126, $legumes['end_time']); - // $allLegumes = model('commission_legumes')->getSum([ - // [ 'end_time', 'between', [ 1704076126, $legumes['end_time'] ] ] - // ],'legumes_num'); - $allLegumes += $legumesNum; - $tomorrowLegumesPrice = sprintf("%.4f",$allIntegralInfo['reality_money'] / $allLegumes); - - // 2024-05-26 00:00:00 - // debug(model('commission_record')->getList([ - // [ 'create_time', 'between', [ date("Y-m-d H:i:s",1704076126), '2024-05-26 00:00:00' ] ] - // ], 'id,integral_money,create_time')); - - echo "
";
-            print_r([
-                'ID' => $legumes['id'],
-                '时间戳' => $legumes['start_time'] . '~' . $legumes['end_time'] ,
-                '时间' => date("Y-m-d H:i:s", $legumes['start_time']) . '~' . date("Y-m-d H:i:s", $legumes['end_time']) ,
-                date("Y-m-d", $legumes['start_time']) . '价格' => $legumesPrice,
-                date("Y-m-d", $legumes['end_time']) . '价格' => $tomorrowLegumesPrice,
-                date("Y-m-d", $legumes['start_time']) . '豆豆数量' => $legumesNum,
-                date("Y-m-d H:i:s", $legumes['start_time']) . '~' . date("Y-m-d H:i:s", $legumes['end_time']) . '积分抽成信息' => [
-                    '总金额' => $integralInfo['total_money'],
-                    '退款减少金额' => $integralInfo['refund_money'],
-                    '实际有效' => $integralInfo['reality_money'],
-                ],
-                "截至".date("Y-m-d H:i:s", $legumes['end_time']).'全平台抽成信息' => [
-                    '总金额' => $allIntegralInfo['total_money'],
-                    '退款减少金额' => $allIntegralInfo['refund_money'],
-                    '实际有效' => $allIntegralInfo['reality_money'],
-                ],
-                "截至".date("Y-m-d H:i:s", $legumes['end_time']).'全平台豆豆数量' => $allLegumes,
-            ]);
-
-
-
-            $updateData[] = [
-                    'id'                     => $legumes['id'],
-                    'total_integral_money'   => (float)$integralInfo['total_money'],// 当前周期积分抽成总金额
-                    'refund_money'           => (float)$integralInfo['refund_money'],// 未结算前 - 已退款金额
-                    'reality_money'          => (float)$integralInfo['reality_money'],// 实际结算时拥有的基金池总数
-                    'legumes_price'          => (float)$legumesPrice,// 豆豆价格(当日价格)
-                    'legumes_num'            => (float)$legumesNum,// 豆豆数量(当日产生数量)
-                    'tomorrow_legumes_price' => (float)$tomorrowLegumesPrice,// 豆豆价格(明日价格)
-                    'status'                 => (float)0,// 状态:0=待分配,1=已分配
-            ];
-
-            echo "

"; - $legumesPrice = $tomorrowLegumesPrice; - } - // 修改信息 - // $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes', 'pk' => 'id'])); - // $goodsSkuModel->saveAll($updateData); - // - // (new Setting())->setLegumesPrice(0, $legumesPrice); - - - - debug("结束"); - } - // 豆豆重新分配 - private function afreshAllocationLegumes(){ - $list = model('commission_legumes')->getList([ - ['id', '>', 23] - ]); - - $updateData = []; - - foreach($list as $item){ - $logList = model('commission_legumes_log')->getList([ - ['legumes_id', '=', $item['id']] - ]); - foreach($logList as $log){ - $updateData[] = [ - 'id' => $log['id'], - 'cycle_total_legumes' => (float)$item['legumes_num'],// 当前周期豆豆总数 - 'get_legumes' => (float)sprintf("%.4f",$item['legumes_num'] * $log['order_money_rate'] / 100),// 当前订单实际获得豆豆 - ]; - } - } - // 修改豆豆积分使用信息 - $goodsSkuModel = (new NewBaseModel(['table_name' => 'commission_legumes_log', 'pk' => 'id'])); - $goodsSkuModel->saveAll($updateData); - - - // 修改豆豆周期分配状态 - $ids = array_column($list, 'id'); - model('commission_legumes')->update(['status' => 1],[ - ['id', 'in', $ids] - ]); - // 触发全平台豆豆转积分操作 - Queue::push(ComputeIntegralJob::class); - - - debug($updateData); - } - // 结算平台抽成相关流水 - private function settlementAccount(){ - $where = [ - ['a.status', '=', 0], - ['a.account_type', '=', 'promoter'] - ]; - $field = 'a.id,a.account_data,a.member_id,o.order_status,o.order_status_name'; - - $join = [ - ['commission_record cr','cr.id = a.join_id', 'left'], - ['order o','o.order_id = cr.order_id', 'left'], - ]; - $list = model('commission_account')->getList($where,$field,'a.id DESC','a',$join); - // 获取用户已经持有信息 - $memberIds = array_column($list, 'member_id'); - $userList = Db::name('member') - ->field('commission_money,member_id') - ->whereIn('member_id', $memberIds) - ->select() - ->toArray(); - $userList = array_column($userList, null, 'member_id'); - debug($userList,false); - $ids = []; - foreach($list as $item){ - if($item['order_status'] == 10){ - $userList[$item['member_id']]['commission_money'] += $item['account_data']; - $ids[] = $item['id']; - } - } - // // 修改 - // $newBaseModel = (new NewBaseModel(['table_name' => 'member', 'pk' => 'member_id'])); - // $userList = array_values($userList); - // $newBaseModel->saveAll($userList); - // // 已结算 - // model('commission_account')->update(['status'=>1],[ - // ['id', 'in', $ids] - // ]); - debug($userList); - } - - - - /******** 数据库批量处理 ***************************************/ - private function sqlInit(){ - // 不清除数据的表 - $notCleanUp = [ - // 'tk_addon - // 'tk_adv - // 'tk_album - // 'tk_album_pic - // 'tk_area - // 'tk_attachments - // 'tk_cashier_auth - // 'tk_cashier_auth_group - // 'tk_cloud_order - - - // 开发中 ...... - - - // 'tk_config - // 'tk_cron - // 'tk_cron_log - // 'tk_diy_template - // 'tk_diy_template_goods - // 'tk_diy_template_goods_item - // 'tk_diy_theme - // 'tk_diy_view_util - // 'tk_document - // 'tk_express_company - // 'tk_express_company_template - // 'tk_express_deliver - // 'tk_express_delivery_package - // 'tk_express_template - // 'tk_express_template_free_shipping - // 'tk_express_template_item - // 'tk_fenxiao - // 'tk_fenxiao_account - // 'tk_fenxiao_goods_sku - // 'tk_fenxiao_level - // 'tk_fenxiao_order - // 'tk_fenxiao_withdraw - // 'tk_form - // 'tk_form_data - // 'tk_goods - // 'tk_goods_attr_class - // 'tk_goods_browse - // 'tk_goods_category - // 'tk_goods_commission - // 'tk_goods_label - // 'tk_goods_service - // 'tk_goods_sku - // 'tk_group - // 'tk_link - // 'tk_local - // 'tk_manage_account - // 'tk_manage_level - // 'tk_manage_order - // 'tk_manage_user - // 'tk_member - // 'tk_member_account - // 'tk_member_address - // 'tk_member_bank_account - // 'tk_member_level - // 'tk_member_level_records - // 'tk_member_recommend - // 'tk_menu - // 'tk_message - // 'tk_message_template - // 'tk_message_variable - // 'tk_order - // 'tk_order_goods - // 'tk_order_log - // 'tk_order_refund_log - // 'tk_pay - // 'tk_pay_notify_log - // 'tk_pay_refund - // 'tk_pay_shop - // 'tk_promotion_bundling - // 'tk_promotion_coupon - // 'tk_promotion_coupon_type - // 'tk_promotion_groupbuy - // 'tk_promotion_jielong - // 'tk_promotion_pinfan - // 'tk_promotion_pinfan_group - // 'tk_promotion_topic - // 'tk_service_category - // 'tk_shop - // 'tk_site - // 'tk_site_diy_template - // 'tk_site_diy_view - // 'tk_site_group - // 'tk_sms_template - // 'tk_stat_shop - // 'tk_stat_shop_hour - // 'tk_stat_store - // 'tk_stat_store_hour - // 'tk_stock_document - // 'tk_stock_document_goods - // 'tk_stock_inventory - // 'tk_stock_inventory_goods - // 'tk_store - // 'tk_store_category - // 'tk_store_goods - // 'tk_store_goods_sku - // 'tk_store_label - // 'tk_store_member - // 'tk_supply_goods_warehousing - // 'tk_supply_order - // 'tk_supply_sub_order - // 'tk_uni_fans - // 'tk_user - // 'tk_user_group - // 'tk_user_log - // 'tk_verifier - // 'tk_verify - // 'tk_verify_record - // 'tk_website - // 'tk_wechat_replay_rule - - - - ]; - // 获取全部数据库列表 - $tables = $this->getAllTable(); - // 获取存在数据的表 - // $hasTable = $this->getHasSpecifyDataTable($tables,$notCleanUp); - $hasTable = $this->getHasDataTable($tables,$notCleanUp); - - debug($hasTable); - // 执行清除操作 - // foreach($tables as $name){ - // if(!in_array($name,$notCleanUp)){ - // // 执行清除操作 - // $res = Db::query('TRUNCATE TABLE '.$name.';'); - // } - // } - - debug("处理完成"); - } - // 数据库处理 - 获取全部数据库 - private function getAllTable(){ - $database = Db::query('SELECT DATABASE() as database_name')[0]['database_name']; - $tables = Db::query('SHOW TABLES'); - return array_column($tables,'Tables_in_'.$database); - } - // 数据库处理 - 获取存在数据的表(任意数据) - private function getHasDataTable($tables,$notCleanUp){ - $tableList = []; - foreach($tables as $tableName){ - if(!in_array($tableName,$notCleanUp)){ - // echo "{$tableName}
\n\r"; - // 获取字段信息 - $result = Db::query("select count(*) as count_data from {$tableName}"); - $countData = $result[0]['count_data'] ?? 0; - if($countData > 0){ - $tableList[] = $tableName; - } - } - } - - return $tableList; - } - // 数据库处理 - 获取存在指定数据的表 - private function getHasSpecifyDataTable($tables,$notCleanUp){ - $tableList = []; - foreach($tables as $tableName){ - if(!in_array($tableName,$notCleanUp)){ - echo "{$tableName}\n\r"; - // 获取字段信息 - $allFieldDesc = Db::query("show columns from {$tableName}"); - $allField = array_column($allFieldDesc,'Field'); - // if($this->isHasSpecifyData($allField,$name)) $tableList[] = $name; - - - $res = $this->isHasSpecifyData($allField,$tableName); - echo $res ? "存在\n\r" : "不存在\n\r"; - if($res){ - // 批量替换 - $query = "UPDATE {$tableName} SET "; - $handleFieldNum = 0; - foreach($allFieldDesc as $fieldInfo){ - if(strpos($fieldInfo['Type'], 'int') !== false || $fieldInfo['Key'] == 'PRI') continue; - - $fieldName = $fieldInfo['Field']; - $query .= "`{$fieldName}` = REPLACE(`{$fieldName}`,'bt.test.cdlfjy.com','zc.test.cdlfjy.com'),"; - ++$handleFieldNum; - } - $query = trim($query); - $query = trim($query,','); - $query = trim($query); - echo "SQL({$handleFieldNum}):{$query}\n"; - if($handleFieldNum > 0) Db::query($query); - } - - echo "\n\n\n"; - } - } - - return $tableList; - } - // 数据库处理 - 判断当前表是否具有指定内容 - private function isHasSpecifyData($allField,$tableName){ - $query = "select * from {$tableName} where ("; - foreach($allField as $fieldName){ - $query .= "`{$fieldName}` like '%bt.test.cdlfjy.com%' OR "; - } - $query = trim($query); - $query = trim($query,'OR'); - $query = trim($query) . ")"; - - $result = Db::query($query); - if($result) return true; - - return false; - } - -} diff --git a/addon/commission/shop/view/index/account_list.html b/addon/commission/shop/view/index/account_list.html deleted file mode 100644 index 48d4474..0000000 --- a/addon/commission/shop/view/index/account_list.html +++ /dev/null @@ -1,199 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - -
-
- - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - -
-
-{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/commission/shop/view/index/index.html b/addon/commission/shop/view/index/index.html deleted file mode 100644 index c914bbe..0000000 --- a/addon/commission/shop/view/index/index.html +++ /dev/null @@ -1,453 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - -
-
- - - - - - - - - - - - - -
-
-
- -
-
-
- - -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/commission/shop/view/index/legumes.html b/addon/commission/shop/view/index/legumes.html deleted file mode 100644 index 6889f6d..0000000 --- a/addon/commission/shop/view/index/legumes.html +++ /dev/null @@ -1,456 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - -
-
- - -
-
-
- -
-
-
- - -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
- - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - -
-
- - -
-
-{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/commission/shop/view/index/partner.html b/addon/commission/shop/view/index/partner.html deleted file mode 100644 index 6d9eb0b..0000000 --- a/addon/commission/shop/view/index/partner.html +++ /dev/null @@ -1,262 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
-{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/commission/shop/view/index/set.html b/addon/commission/shop/view/index/set.html deleted file mode 100644 index ba5882a..0000000 --- a/addon/commission/shop/view/index/set.html +++ /dev/null @@ -1,121 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - - - 关闭 - 开启 - - - - - 提交 - - -
-{/block} - -{block name="script"} - - -{/block} \ No newline at end of file diff --git a/addon/commission/shop/view/index/weight_value.html b/addon/commission/shop/view/index/weight_value.html deleted file mode 100644 index 7f8e90a..0000000 --- a/addon/commission/shop/view/index/weight_value.html +++ /dev/null @@ -1,261 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - - - - -{/block} - -{block name="main"} -
- - -
-
- - - - - - - -
-
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-{/block} - -{block name="script"} - -{/block} \ No newline at end of file diff --git a/addon/fenxiao/event/OrderPay.php b/addon/fenxiao/event/OrderPay.php index fbb6f1f..f65b9ce 100644 --- a/addon/fenxiao/event/OrderPay.php +++ b/addon/fenxiao/event/OrderPay.php @@ -35,7 +35,7 @@ class OrderPay 'member_id' => $order['member_id'], 'action' => 'order_pay', ]); - // 自动成为分销商 + // // 自动成为分销商 $fenxiao_model->autoBecomeFenxiao($order['member_id'], $order['site_id']); $fenxiao_order = new FenxiaoOrder(); $res = $fenxiao_order->calculate($order); diff --git a/addon/fenxiao/model/Config.php b/addon/fenxiao/model/Config.php index 8c1caa6..2c96f26 100644 --- a/addon/fenxiao/model/Config.php +++ b/addon/fenxiao/model/Config.php @@ -38,6 +38,8 @@ class Config extends BaseModel 'is_apply' => $data[ 'is_apply' ],//是否开启分销申请 'is_commission_money' => $data[ 'is_commission_money' ],//是否开启商品详情一级佣金 'is_support_cashier' => $data[ 'is_support_cashier' ],//是否开启商品详情一级佣金 + 'direct_rate' => $data[ 'direct_rate' ],//默认直推 + 'indirect_rate' => $data[ 'indirect_rate' ],//默认间推 ]; $config->setConfig($basics_data, '分销基本配置', $is_use, [ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', 'FENXIAO_BASICS_CONFIG' ] ]); //分销商设置 @@ -80,7 +82,8 @@ class Config extends BaseModel 'internal_buy' => 0,//分销内购 'is_examine' => 0,//是否需要审核 'is_apply' => 0,//分销商申请方式 - 'is_commission_money' => 1,//是否开启商品详情一级佣金 + 'direct_rate' => 0,//是否开启商品详情一级佣金 + 'indirect_rate' => 0,//是否开启商品详情一级佣金 ]; } $res[ 'data' ][ 'value' ][ 'is_commission_money' ] = $res[ 'data' ][ 'value' ][ 'is_commission_money' ] ?? 1; @@ -88,6 +91,8 @@ class Config extends BaseModel $res[ 'data' ][ 'value' ][ 'is_apply' ] = $res[ 'data' ][ 'value' ][ 'is_apply' ] ?? 1; $res[ 'data' ][ 'value' ][ 'level' ] = $res[ 'data' ][ 'value' ][ 'level' ] == 3 ? 2 : $res[ 'data' ][ 'value' ][ 'level' ]; $res[ 'data' ][ 'value' ][ 'is_support_cashier' ] = $res[ 'data' ][ 'value' ][ 'is_support_cashier' ] ?? 0; + $res[ 'data' ][ 'value' ][ 'direct_rate' ] = $res[ 'data' ][ 'value' ][ 'direct_rate' ] ?? 0; + $res[ 'data' ][ 'value' ][ 'indirect_rate' ] = $res[ 'data' ][ 'value' ][ 'indirect_rate' ] ?? 0; return $res; } @@ -317,4 +322,4 @@ class Config extends BaseModel } /******************************************************************** 分销文字配置 end ****************************************************************************/ -} \ No newline at end of file +} diff --git a/addon/fenxiao/model/Fenxiao.php b/addon/fenxiao/model/Fenxiao.php index 95adac0..587bd12 100644 --- a/addon/fenxiao/model/Fenxiao.php +++ b/addon/fenxiao/model/Fenxiao.php @@ -370,8 +370,10 @@ class Fenxiao extends BaseModel if (!$basics_config[ 'level' ]) return $this->error('', '未开启分销'); if ($basics_config[ 'is_apply' ] != 0) return $this->error('', '成为分销商需进行申请'); // 成为分销商的资格 + $fenxiao_config = $config->getFenxiaoConfig($site_id); $fenxiao_config = $fenxiao_config[ 'data' ][ 'value' ]; + switch ( $fenxiao_config[ 'fenxiao_condition' ] ) { case 2: // 消费次数 @@ -428,7 +430,9 @@ class Fenxiao extends BaseModel 'level_id' => $level_info[ 'data' ][ 'level_id' ], 'level_name' => $level_info[ 'data' ][ 'level_name' ] ]; + $res = $this->addFenxiao($data); + return $res; } } diff --git a/addon/fenxiao/model/FenxiaoOrder.php b/addon/fenxiao/model/FenxiaoOrder.php index 4371c18..9830f26 100644 --- a/addon/fenxiao/model/FenxiaoOrder.php +++ b/addon/fenxiao/model/FenxiaoOrder.php @@ -11,6 +11,8 @@ namespace addon\fenxiao\model; use app\model\BaseModel; use app\model\message\Message; use app\model\system\Stat; +use think\facade\Db; + /** * 分销商品 */ @@ -38,11 +40,12 @@ class FenxiaoOrder extends BaseModel ]); $member_info = model("member")->getInfo([ [ 'member_id', '=', $order[ 'member_id' ] ] ], 'fenxiao_id,is_fenxiao,nickname,mobile'); } + // //如果没有分销商直接返回不计算,没有考虑首次付款上下级绑定 if (empty($member_info)) return $this->success(); if ($member_info[ 'fenxiao_id' ] == 0) return $this->success(); $fenxiao_id = $member_info[ 'fenxiao_id' ]; - $field = 'f.fenxiao_id,f.fenxiao_name,f.member_id,f.level_id,f.parent,f.grand_parent,l.level_num'; + $field = 'f.fenxiao_id,f.fenxiao_name,f.member_id,f.level_id,f.site_id,f.status,f.parent,f.grand_parent,f.chain,l.level_num,l.one_rate,l.two_rate'; $join = [ ['fenxiao_level l', 'f.level_id = l.level_id', 'right'] ]; @@ -56,165 +59,170 @@ class FenxiaoOrder extends BaseModel } // //判断几级分销 - dump($fenxiao_basic_config); - dump($fenxiao_info); // $parent_fenxiao_info = $level_config >= 2 ? model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id, fenxiao_name, status, parent') : []; // $grand_parent_fenxiao_info = $level_config >= 3 && !empty($parent_fenxiao_info[ 'parent' ]) ? model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $parent_fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id, fenxiao_name, status') : []; $order_goods = model('order_goods')->getList([ [ 'order_id', '=', $order[ 'order_id' ] ], [ 'is_fenxiao', '=', 1 ] ], 'order_goods_id, goods_id, sku_id, sku_name, sku_image, sku_no, is_virtual, price, cost_price, num, goods_money, cost_money, delivery_no, delivery_status, real_goods_money'); if (empty($order_goods)) return $this->success(); model('fenxiao_order')->delete([ [ 'order_id', '=', $order[ 'order_id' ] ] ]); + foreach($order_goods as $k => $v){ - $goods_info = model('goods')->getInfo([['goods_id','=',$v['goods_id']]],'is_fenxiao, fenxiao_type'); $order_fenxiao_data = [ + 'commission' => 0, + 'commission_rate' => 0, 'one_rate' => 0, 'one_commission' => 0, + 'one_fenxiao_id' => 0, + 'one_fenxiao_name' => '', 'two_rate' => 0, 'two_commission' => 0, + 'two_fenxiao_id' => 0, + 'two_fenxiao_name' => '', + 'wholesale_fenxiao_id' => [], + 'wholesale_rate' => 0, + 'wholesale_commission' => 0, + 'wholesale_fenxiao_detail' => [], ]; + $goods_info = model('goods')->getInfo([['goods_id','=',$v['goods_id']]],'is_fenxiao, fenxiao_type'); //参与了分销商品,有直推间推奖励 if($goods_info['is_fenxiao']){ - $order_fenxiao_data = $this->getPushFenXiaoCommission($fenxiao_info,); - }else{ - + $order_fenxiao_data = $this->getPushFenXiaoCommission($fenxiao_info,$v,$order_fenxiao_data,$goods_info['fenxiao_type'],$fenxiao_basic_config); } + + $order_fenxiao_data = $this->getWholesaleFenXiaoCommission($fenxiao_info,$v,$order_fenxiao_data); + + $data = [ + 'order_id' => $order['order_id'], + 'order_no' => $order['order_no'], + 'order_goods_id' => $v['order_goods_id'], + 'site_id' => $order['site_id'], + 'site_name' => $order['site_name'], + 'goods_id' => $v['goods_id'], + 'sku_id' => $v['sku_id'], + 'sku_name' => $v['sku_name'], + 'sku_image' => $v['sku_image'], + 'price' => $v['price'], + 'num' => $v['num'], + 'real_goods_money' => $v['real_goods_money'], + 'member_id' => $order['member_id'], + 'member_name' => !empty($order['name']) ? $order['name'] : $member_info['nickname'], + 'member_mobile' => !empty($order['mobile']) ? $order['mobile'] : $member_info['mobile'], + 'full_address' => $order['full_address'].$order['address'], + 'commission' => $order_fenxiao_data['commission'], + 'commission_rate' => $order_fenxiao_data['commission_rate'], + 'one_fenxiao_id' => $order_fenxiao_data['one_fenxiao_id'], + 'one_rate' => $order_fenxiao_data['one_rate'], + 'one_commission' => $order_fenxiao_data['one_commission'], + 'one_fenxiao_name' => $order_fenxiao_data['one_fenxiao_name'], + 'two_fenxiao_id' => $order_fenxiao_data['two_fenxiao_id'], + 'two_rate' => $order_fenxiao_data['two_rate'], + 'two_commission' => $order_fenxiao_data['two_commission'], + 'two_fenxiao_name' => $order_fenxiao_data['two_fenxiao_name'], + 'wholesale_fenxiao_id' => json_encode($order_fenxiao_data['wholesale_fenxiao_id']), + 'wholesale_rate' => $order_fenxiao_data['wholesale_rate'], + 'wholesale_commission' => $order_fenxiao_data['wholesale_commission'], + 'wholesale_fenxiao_detail' => json_encode($order_fenxiao_data['wholesale_fenxiao_detail']), + 'create_time' => time() + ]; + model("fenxiao_order")->add($data); } - // //获取分销等级 - // foreach ($order_goods as $k => $v) { - // $v[ 'num' ] = numberFormat($v[ 'num' ]); - // // 判断:是否开启分销 - // if($order['order_from'] == 'cashier'){ - // // 收银台订单 - // $isOpenFenXiao = $fenxiao_basic_config['is_support_cashier'] ?? 0; - // $fenXiaoType = 1; - // }else{ - // // 其他订单 - // $goods_info = model('goods')->getInfo([['goods_id','=',$v['goods_id']]],'is_fenxiao, fenxiao_type'); - // $isOpenFenXiao = $goods_info['is_fenxiao'] ?? 0; - // $fenXiaoType = $goods_info[ 'fenxiao_type' ] ?? 1; - // } - // if($isOpenFenXiao != 1) continue; - // // 配送规格 - // $sku_info = model('goods_sku')->getInfo([ [ 'sku_id', '=', $v[ 'sku_id' ] ] ], 'fenxiao_price'); - // if (!empty($sku_info) && $sku_info[ 'fenxiao_price' ] > 0) $v[ 'real_goods_money' ] = $sku_info[ 'fenxiao_price' ] * $v[ 'num' ]; - // $commission = 0; - // $commission_rate = 0; - // $order_fenxiao_data = [ - // 'one_rate' => 0, - // 'one_commission' => 0, - // 'two_rate' => 0, - // 'two_commission' => 0, - // 'three_rate' => 0, - // ]; - // if ($fenXiaoType == 2) { - // // 自定义分销规则 - // $fenxiao_level = model('fenxiao_goods_sku')->getInfo([ [ 'goods_id', '=', $v[ 'goods_id' ] ], [ 'sku_id', '=', $v[ 'sku_id' ] ], [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ]); - // if (empty($fenxiao_level)) continue; - // if ($fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'one_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'one_rate' ] = $fenxiao_level[ 'one_rate' ]; - // $commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $commission_rate += $order_fenxiao_data[ 'one_rate' ] = round($fenxiao_level[ 'one_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2); - // $commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_money' ] * $v[ 'num' ]; - // } - // } - // if (!empty($parent_fenxiao_info) && $parent_fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'two_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'two_rate' ] = $fenxiao_level[ 'two_rate' ]; - // $commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $commission_rate += $order_fenxiao_data[ 'two_rate' ] = round($fenxiao_level[ 'two_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2); - // $commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_money' ] * $v[ 'num' ]; - // } - // } - // if (!empty($grand_parent_fenxiao_info) && $grand_parent_fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'three_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'three_rate' ] = $fenxiao_level[ 'three_rate' ]; - // $commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $commission_rate += $order_fenxiao_data[ 'three_rate' ] = round($fenxiao_level[ 'three_money' ] * $v[ 'num' ] / $v[ 'real_goods_money' ], 2); - // $commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_money' ] * $v[ 'num' ]; - // } - // } - // } else { - // // 默认规则 - // $fenxiao_level = model('fenxiao_level')->getInfo([ [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ]); - // if ($fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'one_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'one_rate' ] = $fenxiao_level[ 'one_rate' ]; - // $commission += $order_fenxiao_data[ 'one_commission' ] = $fenxiao_level[ 'one_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $order_fenxiao_data[ 'one_rate' ] = 0; - // $order_fenxiao_data[ 'one_commission' ] = 0; - // } - // } - // if (!empty($parent_fenxiao_info) && $parent_fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'two_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'two_rate' ] = $fenxiao_level[ 'two_rate' ]; - // $commission += $order_fenxiao_data[ 'two_commission' ] = $fenxiao_level[ 'two_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $order_fenxiao_data[ 'two_rate' ] = 0; - // $order_fenxiao_data[ 'two_commission' ] = 0; - // } - // } - // if (!empty($grand_parent_fenxiao_info) && $grand_parent_fenxiao_info[ 'status' ] == 1) { - // if ($fenxiao_level[ 'three_rate' ] > 0) { - // $commission_rate += $order_fenxiao_data[ 'three_rate' ] = $fenxiao_level[ 'three_rate' ]; - // $commission += $order_fenxiao_data[ 'three_commission' ] = $fenxiao_level[ 'three_rate' ] * $v[ 'real_goods_money' ] / 100; - // } else { - // $order_fenxiao_data[ 'three_rate' ] = 0; - // $order_fenxiao_data[ 'three_commission' ] = 0; - // } - // } - // } - // //启动分销 - // $siteName = model('site')->getValue([ - // ['site_id', '=', $order['site_id']] - // ], 'site_name'); - // $data = [ - // 'order_id' => $order['order_id'], - // 'order_no' => $order['order_no'], - // 'order_goods_id' => $v['order_goods_id'], - // 'site_id' => $order['site_id'], - // 'site_name' => $siteName, - // 'goods_id' => $v['goods_id'], - // 'sku_id' => $v['sku_id'], - // 'sku_name' => $v['sku_name'], - // 'sku_image' => $v['sku_image'], - // 'price' => $v['price'], - // 'num' => $v['num'], - // 'real_goods_money' => $order_goods[$k]['real_goods_money'], - // 'member_id' => $order['member_id'], - // 'member_name' => !empty($order['name']) ? $order['name'] : $member_info['nickname'], - // 'member_mobile' => !empty($order['mobile']) ? $order['mobile'] : $member_info['mobile'], - // 'full_address' => $order['full_address'].$order['address'], - // 'commission' => $commission, - // 'commission_rate' => $commission_rate, - // 'one_fenxiao_id' => empty($fenxiao_info) ? 0 : $fenxiao_info['fenxiao_id'], - // 'one_rate' => empty($order_fenxiao_data['one_rate']) ? 0 : $order_fenxiao_data['one_rate'], - // 'one_commission' => empty($order_fenxiao_data['one_commission']) ? 0 : $order_fenxiao_data['one_commission'], - // 'one_fenxiao_name' => empty($fenxiao_info) ? '' : $fenxiao_info['fenxiao_name'], - // 'two_fenxiao_id' => empty($parent_fenxiao_info) ? 0 : $parent_fenxiao_info['fenxiao_id'], - // 'two_rate' => empty($order_fenxiao_data['two_rate']) ? 0 : $order_fenxiao_data['two_rate'], - // 'two_commission' => empty($order_fenxiao_data['two_commission']) ? 0 : $order_fenxiao_data['two_commission'], - // 'two_fenxiao_name' => empty($parent_fenxiao_info) ? '' : $parent_fenxiao_info['fenxiao_name'], - // 'three_fenxiao_id' => empty($grand_parent_fenxiao_info) ? '' : $grand_parent_fenxiao_info['fenxiao_id'], - // 'three_rate' => empty($order_fenxiao_data['three_rate']) ? 0 : $order_fenxiao_data['three_rate'], - // 'three_commission' => empty($order_fenxiao_data['three_commission']) ? 0 : $order_fenxiao_data['three_commission'], - // 'three_fenxiao_name' => empty($grand_parent_fenxiao_info) ? '' : $grand_parent_fenxiao_info['fenxiao_name'], - // 'create_time' => time() - // ]; - // - // model("fenxiao_order")->add($data); - // } + // // 分销商检测升级 - // event('FenxiaoUpgrade', [ - // 'fenxiao_id' => $member_info[ 'fenxiao_id' ] - // ]); + event('FenxiaoUpgrade', [ + 'fenxiao_id' => $member_info[ 'fenxiao_id' ] + ]); return $this->success(); } + private function getPushFenXiaoCommission($fenxiao_info,$v,&$order_fenxiao_data,$type,$config){ + if($type == 2){ + $fenxiao_level = model('fenxiao_goods_sku')->getInfo([ [ 'goods_id', '=', $v[ 'goods_id' ] ], [ 'sku_id', '=', $v[ 'sku_id' ] ], [ 'level_id', '=', $fenxiao_info[ 'level_id' ] ] ]); + if (empty($fenxiao_level)) return false; + $one_rate = $fenxiao_level['direct_rate']; + $one_money = $fenxiao_level['direct_money']; + $two_rate = $fenxiao_level['indirect_rate']; + $two_money = $fenxiao_level['indirect_money']; + }else{ + $one_rate = $config['direct_rate']; + $two_rate = $config['indirect_rate']; + $one_money = $two_money = 0; + } + + $parent_fenxiao_info = $fenxiao_info['parent'] > 0 ? model('fenxiao')->getInfo([ [ 'fenxiao_id', '=', $fenxiao_info[ 'parent' ] ], [ 'is_delete', '=', 0 ] ], 'fenxiao_id, fenxiao_name, status, parent') : []; + if ($fenxiao_info[ 'status' ] == 1) { + if ($one_rate > 0) { + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'one_rate' ] = $one_rate; + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'one_commission' ] = $one_rate * $v[ 'real_goods_money' ] / 100; + } else { + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'one_rate' ] = round($one_money * $v[ 'num' ] / $v[ 'real_goods_money' ], 2); + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'one_commission' ] = $one_money * $v[ 'num' ]; + } + $order_fenxiao_data['one_fenxiao_id'] = $fenxiao_info['fenxiao_id']; + $order_fenxiao_data['one_fenxiao_name'] = $fenxiao_info['fenxiao_name']; + } + if (!empty($parent_fenxiao_info) && $parent_fenxiao_info[ 'status' ] == 1) { + if ($two_rate > 0) { + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'two_rate' ] = $two_rate; + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'two_commission' ] = $two_rate * $v[ 'real_goods_money' ] / 100; + } else { + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'two_rate' ] = round($two_money * $v[ 'num' ] / $v[ 'real_goods_money' ], 2); + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'two_commission' ] = $two_money * $v[ 'num' ]; + } + $order_fenxiao_data['two_fenxiao_id'] = $parent_fenxiao_info['fenxiao_id']; + $order_fenxiao_data['two_fenxiao_name'] = $fenxiao_info['fenxiao_name']; + } + return $order_fenxiao_data; + } + + private function getWholesaleFenXiaoCommission($fenxiao_info,$v,&$order_fenxiao_data){ + $order_fenxiao_data['wholesale_fenxiao_id'][] = $fenxiao_info['fenxiao_id']; + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'wholesale_rate' ] = $fenxiao_info[ 'one_rate' ]; + $commission = $fenxiao_info[ 'one_rate' ] * $v[ 'real_goods_money' ] / 100; + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'wholesale_commission' ] = $commission; + $order_fenxiao_data['wholesale_fenxiao_detail'][] = ['name' => $fenxiao_info['fenxiao_name'], 'commission' => $commission]; + $level_List = model('fenxiao_level')->getList([['site_id', '=' ,$fenxiao_info['site_id']],['level_num' , '>' ,$fenxiao_info['level_num']]],'*','level_num asc'); + if($fenxiao_info['chain'] && $level_List){ + $data = explode(',', $fenxiao_info['chain']); + $chain = array_filter($data, function ($value) { + return !empty($value); + }); + // $count = count($chain); + // //要删除最后一个数据,最后一个数据是自己的分销商ID + // //因为逗号分割去除空白后最后一个key会被去掉,所以count不需要 - 1; + // unset($chain[$count]); + $chain = array_values($chain); + $nodeUser = Db::name('fenxiao') + ->where('f.is_delete', '=', 0) + ->alias('f') + ->join('fenxiao_level l', 'f.level_id = l.level_id', 'right') + ->where('f.fenxiao_id', '<>', $fenxiao_info['fenxiao_id']) + ->whereIn('f.fenxiao_id', $chain) + ->field('f.fenxiao_id,f.fenxiao_name,f.member_id,f.level_id,f.site_id,f.fenxiao_name,f.status,l.level_num,l.one_rate,l.two_rate') + ->select(); //获取上级用户 + $nodeUser = $nodeUser ? $nodeUser->toArray() : []; + if(count($nodeUser) > 0){ + $order_fenxiao_data = $this->getWholesaleCommission($nodeUser,$v,$order_fenxiao_data,$level_List); + } + } + return $order_fenxiao_data; + } + + protected function getWholesaleCommission($nodeUser,$v,&$order_fenxiao_data,$level_List){ + //不考虑商品单独规则 + $fenxiao_user_level_num = array_column($nodeUser,'level_num'); + foreach($level_List as $key => $val){ + $search = array_search($val['level_num'],$fenxiao_user_level_num); + if($search){ + $order_fenxiao_data['wholesale_fenxiao_id'][] = $nodeUser[$search]['fenxiao_id']; + $order_fenxiao_data['commission_rate'] += $order_fenxiao_data[ 'wholesale_rate' ] += $val[ 'two_rate' ]; + $commission = $val[ 'two_rate' ] * $v[ 'real_goods_money' ] / 100; + $order_fenxiao_data['commission'] += $order_fenxiao_data[ 'wholesale_commission' ] += $commission; + $order_fenxiao_data['wholesale_fenxiao_detail'][] = ['name' => $nodeUser[$search]['fenxiao_name'], 'commission' => $commission]; + } + } + return $order_fenxiao_data; + } + /** * 订单退款 * @param $order_goods_id diff --git a/addon/fenxiao/shop/controller/Config.php b/addon/fenxiao/shop/controller/Config.php index 4f595db..aa94272 100644 --- a/addon/fenxiao/shop/controller/Config.php +++ b/addon/fenxiao/shop/controller/Config.php @@ -49,6 +49,8 @@ class Config extends BaseShop 'one_rate' => input('one_rate', 0.00), 'two_rate' => input('two_rate', 0.00), 'three_rate' => input('three_rate', 0.00), + 'direct_rate' => input('direct_rate', 0.00), + 'indirect_rate' => input('indirect_rate', 0.00), 'is_support_cashier' => input('is_support_cashier', 0) ]; diff --git a/addon/fenxiao/shop/controller/Goods.php b/addon/fenxiao/shop/controller/Goods.php index e938e2f..0cd0baa 100644 --- a/addon/fenxiao/shop/controller/Goods.php +++ b/addon/fenxiao/shop/controller/Goods.php @@ -8,6 +8,7 @@ * ========================================================= */ namespace addon\fenxiao\shop\controller; +use addon\fenxiao\model\Config; use addon\fenxiao\model\FenxiaoGoodsSku as FenxiaoGoodsSkuModel; use addon\fenxiao\model\FenxiaoLevel as FenxiaoLevelModel; use app\model\goods\Goods as GoodsModel; @@ -120,14 +121,14 @@ class Goods extends BaseShop $fenxiao_skus = input('fenxiao', []); $is_fenxiao = input('is_fenxiao', 0); $fenxiao_price = input('fenxiao_price', []); - + $default_level_id = model('fenxiao_level')->getValue([['site_id', '=' , $this->site_id],['level_num' ,'=' ,0]],'level_id'); $goods_data = [ 'is_fenxiao' => $is_fenxiao, 'fenxiao_type' => $fenxiao_type ]; if ($fenxiao_type == 2) { $fenxiao_goods_sku_data = []; foreach ($fenxiao_skus as $level_id => $level_data) { foreach ($level_data[ 'sku_id' ] as $key => $sku_id) { $fenxiao_total = 0; - $fenxiao_level = [ 'one', 'two', 'three' ]; + $fenxiao_level = [ 'one', 'two', 'three', 'direct', 'indirect' ]; foreach ($fenxiao_level as $level) { $item_rate_array = $level_data[ $level . '_rate' ] ?? []; $item_rate = $item_rate_array[ $key ] ?? 0; @@ -143,7 +144,7 @@ class Goods extends BaseShop $fenxiao_total += $item_money; } } - if (empty($fenxiao_total)) { + if (empty($fenxiao_total) && $level_id != $default_level_id) { return error(-1, '分销金额不可以为零'); } if ($level_data[ 'sku_price' ][ $key ] < $fenxiao_total) { @@ -169,6 +170,10 @@ class Goods extends BaseShop 'two_money' => $two_money ?? 0, 'three_rate' => $three_rate ?? 0, 'three_money' => $three_money ?? 0, + 'direct_rate' => $direct_rate ?? 0, + 'direct_money' => $direct_money ?? 0, + 'indirect_rate' => $indirect_rate ?? 0, + 'indirect_money' => $indirect_money ?? 0, ]; $fenxiao_goods_sku_data[] = $fenxiao_sku; } @@ -178,6 +183,10 @@ class Goods extends BaseShop } if ($fenxiao_type == 1) { $fenxiao_goods_sku_data = []; + $config_model = new Config(); + $fenxiao_basic_config = $config_model->getFenxiaoBasicsConfig($this->site_id)[ 'data' ][ 'value' ]; + $direct_rate = $fenxiao_basic_config['direct_rate']; + $indirect_rate = $fenxiao_basic_config['indirect_rate']; foreach ($fenxiao_level[ 'data' ] as $level) { foreach ($goods_info[ 'data' ][ 'sku_data' ] as $sku) { $item_one_rate = $level[ 'one_rate' ] ?? 0; @@ -200,6 +209,10 @@ class Goods extends BaseShop 'two_money' => 0, 'three_rate' => $item_three_rate, 'three_money' => 0, + 'direct_rate' => $direct_rate, + 'direct_money' => 0, + 'indirect_rate' => $indirect_rate, + 'indirect_money' => 0, ]; $fenxiao_goods_sku_data[] = $fenxiao_sku; } @@ -265,4 +278,4 @@ class Goods extends BaseShop return $fenxiao_goods_model->modifyGoodsIsFenxiao($goods_ids, $is_fenxiao, $this->site_id); } } -} \ No newline at end of file +} diff --git a/addon/fenxiao/shop/view/config/basics.html b/addon/fenxiao/shop/view/config/basics.html index b9a76b7..2161d28 100644 --- a/addon/fenxiao/shop/view/config/basics.html +++ b/addon/fenxiao/shop/view/config/basics.html @@ -217,24 +217,24 @@
- +
%
-

会员购买后给对应分销商的返佣比例

+

会员购买后给对应分销商的默认直推返佣比例

- +
%
-

会员购买后给对应分销商的返佣比例

+

会员购买后给对应分销商的默认间推返佣比例

diff --git a/addon/fenxiao/shop/view/goods/config.html b/addon/fenxiao/shop/view/goods/config.html index 4a17fdf..a3d9723 100644 --- a/addon/fenxiao/shop/view/goods/config.html +++ b/addon/fenxiao/shop/view/goods/config.html @@ -169,8 +169,8 @@
- + @@ -187,13 +187,15 @@ - + {if $fenxiao_config.level >= 2} - + {/if} {if $fenxiao_config.level >= 3} {/if} + + @@ -264,6 +266,36 @@ {/foreach} {/if} + + {/foreach} diff --git a/addon/hyctransfer/api/controller/Account.php b/addon/hyctransfer/api/controller/Account.php deleted file mode 100644 index dc1b50c..0000000 --- a/addon/hyctransfer/api/controller/Account.php +++ /dev/null @@ -1,28 +0,0 @@ -checkToken(); - if ($token['code'] < 0) return $this->response($token); - $member_id = $this->member_id; - $id = input('id'); - $hycmemberId = input('hycmemberId'); - $trans_seq_id = input('transSeqId'); - $contractId = input('contractId'); - $status = input('status'); - if ($hycmemberId && $trans_seq_id) { - $ExternalApi = new ExternalApi($this->site_id, $member_id); - if (!$contractId) { - $res = $ExternalApi->personalContractCreate($id, $hycmemberId); - } else { - $res = $ExternalApi->personalContractQuery($contractId); - } - return $this->response($res); - } - return $this->response(error(-1, '参数错误')); - } -} diff --git a/addon/hyctransfer/api/controller/Notify.php b/addon/hyctransfer/api/controller/Notify.php deleted file mode 100644 index 0dde4ee..0000000 --- a/addon/hyctransfer/api/controller/Notify.php +++ /dev/null @@ -1,50 +0,0 @@ -getInfo(['member_id' => $mer_id, 'trans_seq_id' => $transSeqId]); - if ($staff) { - model('member_bank_account')->update([ - 'status' => $info['status'], - ], ['id' => $staff['id']]); - echo 'RECV_ORD_ID_' . $staff['trans_seq_id']; - } - } else { - echo 'fail'; - } - } - - - /*** - * 代发异步通知 - * @return void - */ - public function notify() - { - try { - // 参数获取并且处理 - $info = input(); - $site_id = input('site_id'); - $mer_id = input('mer_id', 0); - $ExternalApi = new ExternalApi($site_id, $mer_id); - // 为了保证数据的一致性 这里需要调用查询接口进行处理 - $ExternalApi->salaryOutOrderResult($info['attachId']); - echo 'RECV_ORD_ID_' . $info['orderId']; - } catch (\Exception $e) { - Log::debug('------- [异步通知]费用代发 - 申请代发 - 错误 -----' . $e->getMessage()); - echo 'fail'; - } - } -} diff --git a/addon/hyctransfer/config/diy_view.php b/addon/hyctransfer/config/diy_view.php deleted file mode 100644 index 3f95903..0000000 --- a/addon/hyctransfer/config/diy_view.php +++ /dev/null @@ -1,18 +0,0 @@ - [ - ], - 'util' => [ - ], - 'link' => [], -]; diff --git a/addon/hyctransfer/config/event.php b/addon/hyctransfer/config/event.php deleted file mode 100644 index 05204e1..0000000 --- a/addon/hyctransfer/config/event.php +++ /dev/null @@ -1,17 +0,0 @@ - [], - 'listen' => [ - //展示活动 - 'ShowPromotion' => [ - 'addon\hyctransfer\event\ShowPromotion', - ], - 'PersonnelAccess'=>[ - 'addon\hyctransfer\event\PersonnelAccess', - ] - ], - - 'subscribe' => [ - ], -]; diff --git a/addon/hyctransfer/config/info.php b/addon/hyctransfer/config/info.php deleted file mode 100644 index 3d118d5..0000000 --- a/addon/hyctransfer/config/info.php +++ /dev/null @@ -1,21 +0,0 @@ -  | -// +---------------------------------------------------------------------+ -// | Repository | https://github.com/niucloud/framework.git  | -// +---------------------------------------------------------------------+ -return [ - 'name' => 'hyctransfer', - 'title' => '灵活用工转账', - 'description' => '灵活用工转账,可在平台申请发票,作为报销凭证', - 'type' => 'tool', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件 - 'status' => 1, - 'author' => '', - 'version' => '1.0.0', - 'version_no' => '20240505', - 'content' => '', -]; diff --git a/addon/hyctransfer/config/menu_admin.php b/addon/hyctransfer/config/menu_admin.php deleted file mode 100644 index d866ee0..0000000 --- a/addon/hyctransfer/config/menu_admin.php +++ /dev/null @@ -1,7 +0,0 @@ - 'PROMOTION_HYCTRADE', - 'title' => '零工转账', - 'url' => 'hyctransfer://shop/transfer/lists', - 'parent' => 'PROMOTION_TOOL', - 'is_show' => 0, - 'is_control' => 1, - 'is_icon' => 0, - 'picture' => '', - 'picture_select' => '', - 'sort' => 100, - 'child_list' => [ - [ - 'name' => 'PROMOTION_HYCTRADE_OPERATE', - 'title' => '转账记录', - 'url' => 'hyctransfer://shop/transfer/lists', - 'sort' => 1, - 'is_show' => 1, - ], - [ - 'name' => 'PROMOTION_HYCTRADE_ACCOUNT', - 'title' => '入驻人员', - 'url' => 'hyctransfer://shop/account/lists', - 'sort' => 1, - 'is_show' => 1, - ], - [ - 'name' => 'PROMOTION_HYCTRADE_CONFIG', - 'title' => '设置', - 'url' => 'hyctransfer://shop/config/setting', - 'sort' => 2, - 'is_show' => 1 - ], - ] - ] -]; diff --git a/addon/hyctransfer/event/Install.php b/addon/hyctransfer/event/Install.php deleted file mode 100644 index 4574902..0000000 --- a/addon/hyctransfer/event/Install.php +++ /dev/null @@ -1,15 +0,0 @@ -personnelAccess($params); - } - return success(); - } -} diff --git a/addon/hyctransfer/event/ShowPromotion.php b/addon/hyctransfer/event/ShowPromotion.php deleted file mode 100644 index a877397..0000000 --- a/addon/hyctransfer/event/ShowPromotion.php +++ /dev/null @@ -1,33 +0,0 @@ - [], - 'shop' => [ - [ - //插件名称 - 'name' => 'hyctransfer', - //展示分类(根据平台端设置,admin(平台营销),shop:店铺营销,member:会员营销, tool:应用工具) - 'show_type' => 'shop', - //展示主题 - 'title' => '灵工转账', - //展示介绍 - 'description' => '帮助商家转账可获取税务发票', - //展示图标 - 'icon' => 'addon/hyctransfer/icon.png', - //跳转链接 - 'url' => 'hyctransfer://shop/transfer/lists', - ] - ] - ]; - return $data; - } -} diff --git a/addon/hyctransfer/event/UnInstall.php b/addon/hyctransfer/event/UnInstall.php deleted file mode 100644 index 6e06e7c..0000000 --- a/addon/hyctransfer/event/UnInstall.php +++ /dev/null @@ -1,15 +0,0 @@ -getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'HYCTRANSFER_CONFIG']]); - if (empty($res['data']['value'])) { - //默认值设置 - $res['data']['value'] = [ - 'accessId' => '',//接入ID - 'accessSecret' => '',//请求密钥 - 'groundAgentId' => '',//落地公司机构号 - 'bmemberId' => '', //落地公司商户号 - 'coreAgentId' => '',//核心企业机构号 - 'memberId' => '' //核心企业商户号 - ]; - } - return $res; - } - - /*** - * @param $data - * @param $site_id - * @param $app_module - * @return array - */ - public function setConfig($data, $site_id, $app_module = 'shop') - { - $config = new ConfigModel(); - $res = $config->setConfig($data, 'HYCTRANSFER配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'HYCTRANSFER_CONFIG']]); - return $res; - } -} diff --git a/addon/hyctransfer/model/ExternalApi.php b/addon/hyctransfer/model/ExternalApi.php deleted file mode 100644 index c022587..0000000 --- a/addon/hyctransfer/model/ExternalApi.php +++ /dev/null @@ -1,438 +0,0 @@ -getConfig($site_id)['data']['value']; - $this->accessId = $info['accessId']; - $this->accessSecret = $info['accessSecret']; - $this->groundAgentId = $info['groundAgentId']; - $this->bmemberId = $info['bmemberId']; - $this->coreAgentId = $info['coreAgentId']; - $this->memberId = $info['memberId']; - $this->site_id = $site_id; - $this->mer_id = $mer_id; - //$this->apiLink = config('app.USE_STAFF_API_LINK'); - } - - /** - * Common: 发起请求 - 请求接口 - * Author: wu-hui - * Time: 2023/10/08 15:46 - * @param $api - * @param $params - * @return mixed|void - */ - private function requestApi($api, $params) - { - try { - // 获取签名 - $sign = $this->getSign($params); - // 发起请求 - $data = [ - 'jsonStr' => json_encode($params, JSON_UNESCAPED_UNICODE), - 'sign' => $sign, - ]; - $header = [ - 'Content-Type: application/json; charset=utf-8', - 'Cache-Control: no-cache', - 'Pragma: no-cache' - ]; - $result = curlPost($this->apiLink . $api, $data, 30, $header, 'json'); - $result = json_decode($result, true); - $result['jsonStr'] = json_decode($result['jsonStr'], true); - return $result['jsonStr']; - } catch (\Exception $e) { - Log::debug('------- 灵活务工 - 接口请求 - 失败原因 -----' . $e->getMessage()); - return $e->getMessage(); - } - } - - /** - * Common: 发起请求 - 获取签名 - * Author: wu-hui - * Time: 2023/10/08 14:41 - * @param $params - * @return false|string - */ - private function getSign($params) - { - // 按照 key 的 ASCII 字符串顺序升序排列 - ksort($params); - // 获取签名字符串 - $signStr = ''; - foreach ($params as $key => $val) { - $signStr .= is_array($val) ? json_encode($val) : $val; - } - // 获取签名 - return hash_hmac("sha256", $signStr, $this->accessSecret); - } - - /** - * Common: 根据方法名称 返回回调地址 - * Author: wu-hui - * Time: 2023/10/09 11:24 - * @param $funName - * @return string - * @throws Exception - */ - private function getNotifyUrl($funName) - { - $notifyUrl = addon_url('hyctransfer/api/notify/' . $funName, ['site_id' => $this->site_id, 'mer_id' => $this->mer_id]); - return $notifyUrl; - } - - - /** - * Common: 员工入驻 - 申请入驻 - * Author: wu-hui - * Time: 2023/10/08 16:58 - * @param $info - * @return mixed|void - * @throws Exception - */ - public function personnelAccess($info) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'orderId' => date('Ymdis'),// [必填]请求流水号 - 'coreAgentId' => $this->coreAgentId,// [必填]核心企业机构号 - 'groundAgentId' => $this->groundAgentId,// [必填]落地公司机构号 - 'noticeUrl' => $this->getNotifyUrl('access'),// [必填]异步通知地址 - 'name' => $info['realname'],// [必填]账户名称 - // 'jobNum' => '',// [选填]工号 - 'contactTelNo' => $info['mobile'],// [必填]手机号 - // 'bankProvId' => '510000',// [必填]银行所在省 - // 'bankCityId' => '510100',// [必填]银行所在市 - 'cardType' => $info['card_type'] ?? 1,// [必填]卡类型(1-对私/2-对公) - // 'bankName' => '',// [选填]银行名称 - 'bankSubName' => $info['branch_bank_name'] ?? '',// [条件必填]开户银行支行名称,卡类型为2-对公必填 - 'accountIdSdate' => date('Ymd', strtotime($info['startTime'])),// [必填]证件有效期开始时间 $info['startTime'],// [必填]证件有效期开始时间 - // 'accountIdEdate' => '20401107',// [选填]证件有效期终止时间,YYYYMMDD或长期 - 'bankActName' => $info['realname'],// [必填]卡号姓名 - 'cardNum' => $info['bank_account'],// [必填]卡号 - 'accountIdNo' => $info['card_id'],// [必填]持卡人证件号 - 'accountIdType' => '1',// [选填]证件类型(1.身份证 9.其他类型)不填默认1 - 'merType' => $info['mer_type'] ?? 3,// [必填]商户类型 (1-个体户/3-个人) - // 'merName' => '',// [条件必填]商户注册名称 - // 'merShortName' => '',// [条件必填]商户简称 - // 'provId' => '',// [条件必填]商户经营所在省 - // 'cityId' => '',// [条件必填]商户经营所在市 - // 'areaId' => '',// [条件必填]商户经营所在区县 - // 'merAddress' => '',// [条件必填]商户经营地址 - // 'businessCode' => '',// [条件必填]营业执照号 - // 'businessSdate' => '',// [条件必填]营业执照有效期开始日期 - // 'businessEdate' => '',// [条件必填]营业执照有效期结束日期,YYYYMMDD或长期 - ]; - // 发起请求 - $result = $this->requestApi('/api/personnel/personnelAccess', $params); - if ((int)$result['respCode'] === 0) { - $param['hycmemberId'] = $result['memberId']; - $param['trans_seq_id'] = $result['transSeqId']; - $param['status'] = $result['state'] ?? 0; - return $this->success($param); - } else { - return $this->error($result['respDesc']); - } - } - - public function updatePersonnel($info) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'orderId' => date('Ymdis'),// [必填]请求流水号 - 'coreAgentId' => $this->coreAgentId,// [必填]核心企业机构号 - 'groundAgentId' => $this->groundAgentId,// [必填]落地公司机构号 - 'noticeUrl' => $this->getNotifyUrl('access'),// [必填]异步通知地址 - 'name' => $info['realname'],// [必填]账户名称 - // 'jobNum' => '',// [选填]工号 - 'contactTelNo' => $info['mobile'],// [必填]手机号 - // 'bankProvId' => '510000',// [必填]银行所在省 - // 'bankCityId' => '510100',// [必填]银行所在市 - 'cardType' => $info['card_type'] ?? 1,// [必填]卡类型(1-对私/2-对公) - // 'bankName' => '',// [选填]银行名称 - 'bankSubName' => $info['branch_bank_name'] ?? '',// [条件必填]开户银行支行名称,卡类型为2-对公必填 - 'accountIdSdate' => date('Ymd', strtotime($info['startTime'])),// [必填]证件有效期开始时间 $info['startTime'],// [必填]证件有效期开始时间 - // 'accountIdEdate' => '20401107',// [选填]证件有效期终止时间,YYYYMMDD或长期 - 'bankActName' => $info['realname'],// [必填]卡号姓名 - 'cardNum' => $info['bank_account'],// [必填]卡号 - 'accountIdNo' => $info['card_id'],// [必填]持卡人证件号 - 'accountIdType' => '1',// [选填]证件类型(1.身份证 9.其他类型)不填默认1 - 'merType' => $info['mer_type'] ?? 3,// [必填]商户类型 (1-个体户/3-个人) - // 'merName' => '',// [条件必填]商户注册名称 - // 'merShortName' => '',// [条件必填]商户简称 - // 'provId' => '',// [条件必填]商户经营所在省 - // 'cityId' => '',// [条件必填]商户经营所在市 - // 'areaId' => '',// [条件必填]商户经营所在区县 - // 'merAddress' => '',// [条件必填]商户经营地址 - // 'businessCode' => '',// [条件必填]营业执照号 - // 'businessSdate' => '',// [条件必填]营业执照有效期开始日期 - // 'businessEdate' => '',// [条件必填]营业执照有效期结束日期,YYYYMMDD或长期 - ]; - // 发起请求 - $result = $this->requestApi('/api/personnel/updatePersonnel', $params); - if ((int)$result['respCode'] === 0) { - $param['hycmemberId'] = $result['memberId']; - $param['trans_seq_id'] = $result['transSeqId']; - $param['status'] = $result['state'] ?? 0; - return $this->success($param); - } else { - return $this->error($result['respDesc']); - } - } - - /** - * Common: 员工入驻 - 入驻结果查询 - * Author: wu-hui - * Time: 2023/10/08 17:02 - * @param $memberId - * @param $transSeqId - * @return mixed|void - * @throws Exception - */ - public function personnelResult($memberId, $transSeqId) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'transSeqId' => $transSeqId,// [选填]系统流水号 - 'memberId' => $memberId,// [选填]会员号 - ]; - // 发起请求 - $result = $this->requestApi('/api/personnel/queryPersonnel', $params); - if ((int)$result['respCode'] === 0) { - - return $this->success($result); - } else { - return $this->error($result['respDesc']); - } - } - - - /** - * Common: 员工签约 - * Author: wu-hui - * Time: 2023/10/08 17:46 - * @param $uid - * @return mixed|void - * @throws Exception - */ - public function personalContractCreate($id, $memberId) - { - // 获取员工信息 - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'orderId' => date('Ymdis'),// [必填]请求流水号 - 'coreAgentId' => $this->coreAgentId,// [必填]核心企业机构号 - 'groundAgentId' => $this->groundAgentId,// [必填]落地公司机构号 - 'memberId' => $memberId,// [必填]个人会员号 - 'signResultViewUrl' => '',// [选填]签约结果提示显示页面 - ]; - // 发起请求 - $result = $this->requestApi('/api/contract/personalContractCreate', $params); - if ((int)$result['respCode'] === 0) { - $signState = $result['signState'] ?? 0; - if ($signState == 1) { - $signState = 4; - } - model('member_bank_account')->update([ - 'contractId' => $result['contractId'], - 'status' => $signState, - ], ['id' => $id]); - $result['downUrl'] = urldecode($result['downUrl']); - $result['signUrl'] = urldecode($result['signUrl']); - $result['viewUrl'] = urldecode($result['viewUrl']); - return $this->success($result); - } else { - return $this->error($result['respDesc']); - } - } - - /** - * Common: 员工签约 - 签约结果查询 - * Author: wu-hui - * Time: 2023/10/08 17:50 - * @param $memberId - * @return mixed|void - * @throws Exception - */ - public function personalContractQuery($contract_id) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'orderId' => date('Ymdis'),// [必填]请求流水号 - 'contractId' => $contract_id,// [必填]核心企业机构号 - ]; - // 发起请求 - $result = $this->requestApi('/api/contract/personalContractQuery', $params); - if ((int)$result['respCode'] === 0) { - return $this->success($result); - } else { - return $this->error($result['respDesc']); - } - } - - - public function queryTax($memberId,$startDate='',$endDate='') - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'memberId' => $memberId,// [必填]请求流水号 - 'startDate' => $startDate,// [必填]请求流水号yyyymmdd - 'endDate' => $endDate,// [必填]请求流水号 - ]; - // 发起请求 - $result = $this->requestApi('/api/taxcertificate/queryTax', $params); - if ((int)$result['respCode'] === 0) { - return $this->success($result); - }else{ - return $this->error($result['respDesc']); - } - } - - /** - * Common: 获取税票 - * Author: wu-hui - * Time: 2023/10/08 17:50 - * @param $memberId - * @return mixed|void - * @throws Exception - */ - public function downCertificate($memberId, $taxId) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'memberId' => $memberId,// [必填]请求流水号 - 'taxId' => $taxId,// [必填]请求流水号 - ]; - // 发起请求 - $result = $this->requestApi('/api/taxcertificate/downCertificate', $params); - if ((int)$result['respCode'] === 0) { - return $this->success($result); - }else{ - return $this->error($result['respDesc']); - } - } - - /** - * Common: 费用代发 - 申请代发 - * Author: wu-hui - * Time: 2023/10/09 10:15 - * @param $info - * @return mixed|void - * @throws Exception - */ - public function salaryModelOutOrder($info) - { - // 获取员工信息 - $staff = UseStaff::getSingleInfo($info); - // 基本参数 - $orderNo = createNo('YCH', 6, TRUE); - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'orderId' => $orderNo,// [必填]请求流水号 - 'agentId' => $this->coreAgentId,// [必填]核心企业机构号 - 'bmemberId' => $this->bmemberId,// [必填]落地公司商户号,落地公司memberId - 'salaryModle' => '2',// [必填]代发模式,1-普票 2-专票 - 'accountModle' => '2',// [必填]走账模式,2-代发 - 'modeIdcompany' => '1',// [必填]走账类型,1-单账户模式 - 'noticeUrl' => $this->getNotifyUrl('notify'),// [必填]异步通知地址 - // [必填]代发费用明细 - 'batchSalaryOutOrderModleDtos' => [[ - 'memberId' => $staff['member_id'],// [必填]会员号 - 'outOrderId' => $orderNo,// [必填]外部订单号 - 'salary' => $info['salary'],// [必填]费用金额 - 'salaryMonth' => $info['month'],// [必填]月份,格式:YYYYMM - ]], - ]; - // 发起请求 - $result = $this->requestApi('/api/salaryInfo/salaryModleOutOrder', $params); - if ((int)$result['respCode'] === 2) { - $time = time(); -// UseStaffSalary::insert([ -// 'uniacid' => \YunShop::app()->uniacid, -// 'uid' => $info['uid'], -// 'order_no' => $orderNo, -// 'member_id' => $staff['member_id'], -// 'salary' => $info['salary'], -// 'salary_month' => $info['month'], -// 'attach_id' => $result['attachId'], -// 'created_at' => $time, -// 'updated_at' => $time, -// ]); - return $this->success($result); - } else { - return $this->error($result['respDesc']); - } - } - - /** - * Common: 费用代发 - 结果查询 - * Author: wu-hui - * Time: 2023/10/09 10:51 - * @param $attachId - * @return mixed|void - * @throws Exception - */ - public function salaryOutOrderResult($attachId) - { - // 基本参数 - $params = [ - 'accessId' => $this->accessId,// [必填]接入ID - 'memberId' => $this->memberId,// [必填]智汇管家代理商会员号 - 'attachId' => $attachId,// [条件必填]若订单号未填,则批次号必填 - // 'orderId' => $this->accessId,// [条件必填]若批次号未填,则订单号必填 - ]; - // 发起请求 - $result = $this->requestApi('/api/queryresult/salaryOutOrderResult', $params); - if ((int)$result['respCode'] === 0) { -// $salaryOutOrderRespDto = $result['salaryOutOrderRespDto']; -// $first = collect($salaryOutOrderRespDto)->first(); -// UseStaffSalary::where('attach_id', $attachId) -// ->update([ -// 'attach_state' => $result['attachState'], -// 'order_amt' => $first['orderAmt'], -// 'real_trans_amt' => $first['realTransAmt'], -// 'out_member_id' => $first['outMemberId'], -// 'salary_state' => $first['salaryState'], -// 'trans_fee' => $first['transFee'], -// ]); - return $this->success($result); - } else { - return $this->error($result['respDesc']); - } - } -} diff --git a/addon/hyctransfer/model/PersonnelAccess.php b/addon/hyctransfer/model/PersonnelAccess.php deleted file mode 100644 index 364af65..0000000 --- a/addon/hyctransfer/model/PersonnelAccess.php +++ /dev/null @@ -1,8 +0,0 @@ -isAjax()) { - $member_bank_account_model = new MemberBankAccountModel(); - $condition = [ - ['site_id', '=', $this->site_id], - ['withdraw_type', '=', 'bank'], - ['is_flexible_transfer', '=', 1] - ]; - $page = input('page', 1); - $page_size = input('page_size', PAGE_LIST_ROWS); - - $start_time = input('start_time', ''); - $end_time = input('end_time', ''); - if ($start_time) { - $condition[] = ['end_time', '>=', date_to_time($start_time)]; - } - if ($end_time) { - $condition[] = ['start_time', '<=', date_to_time($end_time)]; - } - $list = $member_bank_account_model->getMemberBankAccountPageList($condition, $page, $page_size); - return $list; - } - $this->forthMenu(); - return $this->fetch('account/lists'); - } - - public function info() - { - $id = input('id'); - $hycmemberId = input('hycmemberId'); - $trans_seq_id = input('transSeqId'); - $contractId = input('contractId'); - $status = input('status'); - if ($hycmemberId && $trans_seq_id) { - $ExternalApi = new ExternalApi($this->site_id, 0); - if (!$contractId) { - $res = $ExternalApi->personalContractCreate($id, $hycmemberId); - } else { - $res = $ExternalApi->personalContractQuery($contractId); - } - return $res; - } - return error('', ''); - } -} diff --git a/addon/hyctransfer/shop/controller/Config.php b/addon/hyctransfer/shop/controller/Config.php deleted file mode 100644 index 8c4c445..0000000 --- a/addon/hyctransfer/shop/controller/Config.php +++ /dev/null @@ -1,22 +0,0 @@ -isAjax()) { - $data = request()->post(); - return $config_model->setConfig($data, $this->site_id); - } - $this->assign('config', $config_model->getConfig($this->site_id)['data']['value']); - $this->forthMenu(); - return $this->fetch('config/index'); - } -} diff --git a/addon/hyctransfer/shop/controller/Transfer.php b/addon/hyctransfer/shop/controller/Transfer.php deleted file mode 100644 index 7996c63..0000000 --- a/addon/hyctransfer/shop/controller/Transfer.php +++ /dev/null @@ -1,22 +0,0 @@ -isAjax()) { - - } - - - $this->forthMenu(); - return $this->fetch('transfer/lists'); - } - -} diff --git a/addon/hyctransfer/shop/view/account/lists.html b/addon/hyctransfer/shop/view/account/lists.html deleted file mode 100644 index 830dc6f..0000000 --- a/addon/hyctransfer/shop/view/account/lists.html +++ /dev/null @@ -1,223 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} - - - -
-
- -
- -
-
-
-
-
- -
- - -
-
-
-
- - -
-
-
-
- - -
- - -

价格

分销商等级名称

直推佣金比例一级佣金比例间推佣金比例二级佣金比例三级佣金比例直推佣金比例间推佣金比例
+ {foreach $goods_info['sku_data'] as $sku} + {if isset($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id])} +
+
0}disabled{/if} > %
+
0}disabled{/if} > 元
+
+ {else/} +
+
%
+
+
+ {/if} + {/foreach} +
+ {foreach $goods_info['sku_data'] as $sku} + {if isset($goods_info['fenxiao_skus'][$level.level_id . '_' . $sku.sku_id])} +
+
0}disabled{/if} > %
+
0}disabled{/if} > 元
+
+ {else/} +
+
%
+
+
+ {/if} + {/foreach} +
- - - - -{/block} -{block name="script"} - -{/block} diff --git a/addon/hyctransfer/shop/view/config/index.html b/addon/hyctransfer/shop/view/config/index.html deleted file mode 100644 index 913abf3..0000000 --- a/addon/hyctransfer/shop/view/config/index.html +++ /dev/null @@ -1,75 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
-
-{/block} -{block name="script"} - -{/block} diff --git a/addon/hyctransfer/shop/view/transfer/lists.html b/addon/hyctransfer/shop/view/transfer/lists.html deleted file mode 100644 index 48f0b25..0000000 --- a/addon/hyctransfer/shop/view/transfer/lists.html +++ /dev/null @@ -1,312 +0,0 @@ -{extend name="app/shop/view/base.html"/} -{block name="resources"} - -{/block} -{block name="main"} - - -
-
-
- -
- -
-
-
-
-
- -
- - -
-
-
-
- - -
-
-
-
- - -
-
- -
- - - - - - -{/block} -{block name="script"} - -{/block} diff --git a/app/model/system/Addon.php b/app/model/system/Addon.php index d9d21ce..ef4735c 100644 --- a/app/model/system/Addon.php +++ b/app/model/system/Addon.php @@ -563,9 +563,14 @@ class Addon extends BaseModel { $addon_list = model('addon')->getList([], 'name'); $menu_model = new Menu(); + // $addon_menu_res = $menu_model->refreshMenu('shop', 'payqrcode'); + // dump($addon_menu_res);die; foreach ($addon_list as $k => $v) { $addon_menu_res = $menu_model->refreshMenu('shop', $v['name']); - // 刷新收银端权限 + // $addon_menu_res = $menu_model->refreshMenu('shop', 'alisms'); + // dump($addon_menu_res); + + // // 刷新收银端权限 $menu_model->refreshCashierAuth($v['name'], $is_truncate_table); } return $this->success($addon_menu_res); diff --git a/app/model/system/Config.php b/app/model/system/Config.php index 8a8343d..72757a1 100644 --- a/app/model/system/Config.php +++ b/app/model/system/Config.php @@ -155,4 +155,4 @@ class Config extends BaseModel $res = model('config')->delete($condition); $this->success($res); } -} \ No newline at end of file +} diff --git a/app/model/system/Menu.php b/app/model/system/Menu.php index 79879e2..7a33629 100644 --- a/app/model/system/Menu.php +++ b/app/model/system/Menu.php @@ -132,6 +132,7 @@ class Menu extends BaseModel if ($is_truncate_table == false) { model('menu')->delete([['app_module', "=", $app_module], ['addon', "=", $addon]]); } + $tree = require $tree_name; $list = $this->getAddonMenuList($tree, $app_module, $addon); if (!empty($list)) { diff --git a/app/pay/controller/Test.php b/app/pay/controller/Test.php index 31c3f14..89de92f 100644 --- a/app/pay/controller/Test.php +++ b/app/pay/controller/Test.php @@ -5,36 +5,28 @@ namespace app\pay\controller; use addon\aliapp\model\CloudPay; use addon\aliapp\model\MinCode; use addon\alipay\model\Pay as PayModel; -use addon\dividemoney\model\OrderPay; +use addon\fenxiao\event\OrderPay; use addon\fenxiao\model\Fenxiao as FenxiaoModel; -use addon\fenxiao\model\FenxiaoOrder; -use addon\team\model\Commission; -use addon\weapp\model\Weapp; + use app\model\diy\Template; -use app\model\message\Message; use app\model\order\Order as OrderModel; -use app\model\system\Cron; use EasyWeChat\Factory; use extend\api\HttpClient; use extend\Kdzhushou; -use extend\Time; use think\Exception; use think\facade\Cache; use think\facade\Db; -use EasyWeChat\Kernel\BaseClient; -use addon\weapp\model\Order; -use think\facade\Queue; -use think\helper\Str; + use EasyWeChat\Kernel\Messages\TextCard; class Test{ // public function test(){ - $orderId = 230; + $orderId = 1; $order_info = model('order')->getInfo(['order_id' => $orderId]); - $fenxiao_order = new FenxiaoOrder(); - $res = $fenxiao_order->calculate($order_info); + $fenxiao_order = new OrderPay(); + $res = $fenxiao_order->handle($order_info); dump($res);die; // $memberId = 21; // (new Commission())->commissionHandleInit($orderId, $memberId); diff --git a/app/shop/controller/System.php b/app/shop/controller/System.php index 45b5d61..05701a1 100644 --- a/app/shop/controller/System.php +++ b/app/shop/controller/System.php @@ -62,8 +62,10 @@ class System extends BaseShop $menu->refreshMenu('store', 'store', true); $menu->refreshMenu('supply', 'supply', true); // 清空收银台菜单表,防止自增ID越来越多 + model('cashier_auth')->execute("TRUNCATE TABLE {$prefix}cashier_auth"); $addon_model->cacheAddonMenu(true); + $addon_model->cacheAddon(); Cache::clear(); $msg = '刷新菜单成功';