diff --git a/app/common/dao/system/AppUpdateDao.php b/app/common/dao/system/AppUpdateDao.php index be39bb94..2f626ec6 100644 --- a/app/common/dao/system/AppUpdateDao.php +++ b/app/common/dao/system/AppUpdateDao.php @@ -40,6 +40,7 @@ class AppUpdateDao extends BaseDao public function search(array $where = []) { + return AppUpdate::getDB() ->when(isset($where['id']) && $where['id'] !== '',function($query) use($where){ $query->where('id',$where['id']); diff --git a/app/common/model/system/AppUpdate.php b/app/common/model/system/AppUpdate.php index e9b57ba2..be38de35 100644 --- a/app/common/model/system/AppUpdate.php +++ b/app/common/model/system/AppUpdate.php @@ -9,6 +9,9 @@ class AppUpdate extends BaseModel public static function tablePk(): string { + + + return 'id'; } diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 91b671fb..fea25d9a 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -66,6 +66,23 @@ class ProductRepository extends BaseRepository public $saleType; protected $dao; const CREATE_PARAMS = [ + "is_copy", "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "unit_name", "sort", "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free', 'param_temp_id', 'extend', 'mer_form_id', + ["mer_cate_id", []], + ['refund_switch', 1], + ["brand_id", 0], + ['once_max_count', 0], + ['once_min_count', 0], + ['pay_limit', 0], + ["attrValue", []], + ['give_coupon_ids', []], + ['type', 0], + ['svip_price', 0], + ['svip_price_type', 0], + ['params', []], + ['product_type', 0], + ['good_ids', []], + ]; + const UPDATE_PARAMS = [ "is_copy", "image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "unit_name", "sort", "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free', 'param_temp_id', 'extend', 'mer_form_id','wholesale_price', ["mer_cate_id", []], ['refund_switch', 1], @@ -235,15 +252,12 @@ class ProductRepository extends BaseRepository $admin_info = $data['admin_info'] ?? []; unset($data['admin_info']); } -// dump($data); $product = $this->setProduct($data); - $product['wholesale_price'] = 11; -// halt($product); event('product.create.before', compact('data', 'productType', 'conType')); return Db::transaction(function () use ($data, $productType, $conType, $content, $product, $admin_info) { $activity_id = 0; $result = $this->dao->create($product); - $settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0); + $settleParams = $this->setAttrValue($data, $result->product_id, $productType, 0, $data['mer_id']); $settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $result->product_id, $data['mer_id']); $settleParams['attr'] = $this->setAttr($data['attr'], $result->product_id); if ($productType == 0) app()->make(ParameterValueRepository::class)->create($result->product_id, $data['params'] ?? [], $data['mer_id']); @@ -293,7 +307,9 @@ class ProductRepository extends BaseRepository } event('product.update.before', compact('id', 'data', 'merId', 'productType', 'conType')); $spuData = $product = $this->setProduct($data);//商品主表 - $settleParams = $this->setAttrValue($data, $id, $productType, 1); + $settleParams = $this->setAttrValue($data, $id, $productType, 1,$merId); + + $settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $id, $merId); $settleParams['attr'] = $this->setAttr($data['attr'], $id); $content = [ @@ -308,6 +324,11 @@ class ProductRepository extends BaseRepository unset($data['admin_info']); } + if(!empty($settleParams['attrValue'])){ + $wholesalePrices = array_column($settleParams['attrValue'], 'wholesale_price'); + $minWholesalePrice = min($wholesalePrices); + $product['wholesale_price'] =$minWholesalePrice; + } return Db::transaction(function () use ($id, $data, $productType, $settleParams, $content, $product, $spuData, $merId) { $productData = $this->save($id, $settleParams, $content, $product, $productType); @@ -405,7 +426,6 @@ class ProductRepository extends BaseRepository unset($data['admin_info']); } $update_infos = $settleParams['update_infos'] ?? []; - if (isset($settleParams['data'])) $data = array_merge($data, $settleParams['data']); $this->dao->update($id, $data); if (isset($data['status']) && $data['status'] !== 1) { @@ -499,6 +519,9 @@ class ProductRepository extends BaseRepository } + $wholesalePrices = array_column($data['attrValue'], 'wholesale_price'); + $minPriceOtPrice = min($wholesalePrices); + $result = [ 'store_name' => $data['store_name'], 'image' => $data['image'], @@ -531,7 +554,7 @@ class ProductRepository extends BaseRepository 'refund_switch' => $data['refund_switch'] ?? 0, 'mer_form_id' => $data['mer_form_id'] ?? 0, 'rate' => $data['rate'] ?? 5.0, - 'wholesale_price'=>$data['wholesale_price'] ??0 + 'wholesale_price'=> $minPriceOtPrice ]; if (isset($data['extend'])) $result['extend'] = $data['extend'] ? json_encode($data['extend'], JSON_UNESCAPED_UNICODE) : ''; @@ -606,8 +629,11 @@ class ProductRepository extends BaseRepository * @param int $productId * @return mixed */ - public function setAttrValue(array $data, int $productId, int $productType, int $isUpdate = 0) + public function setAttrValue(array $data, int $productId, int $productType, int $isUpdate = 0, int $merId = 0) { + if ($merId <= 0) { + throw new ValidateException('添加商品商户id不能为0'); + } $extension_status = systemConfig('extension_status'); if ($isUpdate) { $productAttrValue = app()->make(ProductAttrValueRepository::class)->search(['product_id' => $productId])->select()->toArray(); @@ -653,8 +679,13 @@ class ProductRepository extends BaseRepository !$cdkeey_stock ?: $value['stock'] = $cdkeey_stock; } $new_price = $value['price'] ? (($value['price'] < 0) ? 0 : $value['price']) : 0; + $otPrice = $value['ot_price'] ? (($value['ot_price'] < 0) ? 0 : $value['ot_price']) : 0; + if(isset($value['wholesale_price'])){ + $wholesale_price = $value['wholesale_price'] ? (($value['wholesale_price'] < 0) ? 0 : $value['wholesale_price']) : 0; + }else{ + $wholesale_price = min($new_price,$otPrice); + } - $wholesale_price = $value['wholesale_price'] ? (($value['wholesale_price'] < 0) ? 0 : $value['wholesale_price']) : 0; $new_stock = $value['stock'] ? (($value['stock'] < 0) ? 0 : $value['stock']) : 0; $array = [ 'detail' => json_encode($value['detail'] ?? ''), @@ -666,10 +697,11 @@ class ProductRepository extends BaseRepository "volume" => isset($value['volume']) ? ($value['volume'] ? (($value['volume'] < 0) ? 0 : $value['volume']) : 0) : 0, "weight" => isset($value['weight']) ? ($value['weight'] ? (($value['weight'] < 0) ? 0 : $value['weight']) : 0) : 0, "stock" => $new_stock, - "ot_price" => $value['ot_price'] ? (($value['ot_price'] < 0) ? 0 : $value['ot_price']) : 0, + "ot_price" =>$otPrice, "extension_one" => $extension_status ? ($value['extension_one'] ?? 0) : 0, "extension_two" => $extension_status ? ($value['extension_two'] ?? 0) : 0, "product_id" => $productId, + 'mer_id' => $merId, "type" => 0, "sku" => $sku, "unique" => $unique, @@ -2527,6 +2559,7 @@ class ProductRepository extends BaseRepository $valueNew[$count]['cost'] = $skuValue[$suk]['cost'] ?? 0; $valueNew[$count]['image'] = $skuValue[$suk]['image'] ?? ''; $valueNew[$count]['price'] = $skuValue[$suk]['price'] ?? 0; + $valueNew[$count]['wholesale_price'] = $skuValue[$suk]['wholesale_price'] ?? 0; $valueNew[$count]['stock'] = $skuValue[$suk]['stock'] ?? 0; $valueNew[$count]['cdkey'] = $skuValue[$suk]['cdkey'] ?? []; $valueNew[$count]['weight'] = $skuValue[$suk]['weight'] ?? 0; diff --git a/app/common/repositories/system/LhappRepository.php b/app/common/repositories/system/LhappRepository.php index 2568824b..31ee4ee4 100644 --- a/app/common/repositories/system/LhappRepository.php +++ b/app/common/repositories/system/LhappRepository.php @@ -25,7 +25,7 @@ use think\facade\Cache; * @package app\common\repositories\system * @author xaboy * @day 2020-04-24 - * @mixin CacheDao + * @mixin */ class LhappRepository extends BaseRepository { @@ -33,7 +33,7 @@ class LhappRepository extends BaseRepository /** * CacheRepository constructor. - * @param CacheDao $dao + * @param $dao */ public function __construct(AppUpdateDao $dao) { diff --git a/app/controller/admin/system/Lhapp.php b/app/controller/admin/system/Lhapp.php index 344ce0bd..a4461962 100644 --- a/app/controller/admin/system/Lhapp.php +++ b/app/controller/admin/system/Lhapp.php @@ -34,6 +34,7 @@ class Lhapp extends BaseController public function list() { + [$page, $limit] = $this->getPage(); $where = $this->request->params(['type']); return app('json')->success($this->repository->getList($where, $page, $limit)); diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index e9e5c43a..7a7b6161 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -23,6 +23,7 @@ use app\common\repositories\delivery\DeliveryOrderRepository; use app\common\repositories\store\product\ProductAssistSetRepository; use app\common\repositories\store\product\ProductGroupBuyingRepository; use app\common\repositories\store\product\ProductGroupRepository; +use app\common\repositories\store\product\ProductLabelRepository; use app\common\repositories\store\product\ProductPresellRepository; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\store\shipping\ExpressRepository; @@ -739,4 +740,18 @@ class Common extends BaseController } } + /** + * 商品标签 + */ + public function label_lst(ProductLabelRepository $repository) + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['name', 'type', 'status']); + $data = $repository->getList($where, $page, $limit); + return app('json')->success($data); + } + + + + } diff --git a/app/controller/api/Demo.php b/app/controller/api/Demo.php index 8a5c0fe2..c85f8a1c 100644 --- a/app/controller/api/Demo.php +++ b/app/controller/api/Demo.php @@ -10,6 +10,8 @@ class Demo extends BaseController $order=['auth_code'=>$name]; $a=WechatService::create()->micropay()->scanCode($order); + // $a = WechatService::create()->jsPay(null, 'wx'.time(), 1, '支付测试', 'APP支付测试', '', 'APP'); + halt($a); } } \ No newline at end of file diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index 464a8d8e..700d6295 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -135,7 +135,7 @@ class Product extends BaseController */ public function update($id) { - $params = $this->request->params($this->repository::CREATE_PARAMS); + $params = $this->request->params($this->repository::UPDATE_PARAMS); $data = $this->repository->checkParams($params, $this->request->merId(), $id); if (!$this->repository->merExists($this->request->merId(), $id)) return app('json')->fail('数据不存在'); diff --git a/crmeb/services/WechatService.php b/crmeb/services/WechatService.php index 34f0dccf..32b04b96 100644 --- a/crmeb/services/WechatService.php +++ b/crmeb/services/WechatService.php @@ -994,7 +994,7 @@ class WechatService return $this->application->combinePay; } - /** + /** 条码支付 * @return easywechat\micropay\Client */ public function micropay() diff --git a/crmeb/services/easywechat/micropay/Client.php b/crmeb/services/easywechat/micropay/Client.php index 14c0e9c3..6387080b 100644 --- a/crmeb/services/easywechat/micropay/Client.php +++ b/crmeb/services/easywechat/micropay/Client.php @@ -12,31 +12,44 @@ namespace crmeb\services\easywechat\micropay; - use crmeb\services\easywechat\BaseClient; class Client extends BaseClient { - + + /** + * 条码支付 + */ public function scanCode($order) { - $content=[ - 'appid'=>$this->app['config']['app_id'], - 'mch_id'=>2, - 'device_info'=>3, - 'body'=>'线下支付', - 'attach'=>'测试数据', - 'out_trade_no'=>time(), - 'total_fee'=>1, - 'spbill_create_ip'=>request()->ip(), - 'auth_code'=>$order['auth_code'], + + $content = [ + 'appid' => $this->app['config']['app_id'], + 'mch_id' => $this->app['config']['payment']['merchant_id'], + 'body' => $order['body'], + 'nonce_str' => $order['order_sn'], + 'total_fee' => $order['pay_price'], + 'spbill_create_ip' => request()->ip(), + 'auth_code' => (string)$order['auth_code'], ]; - $content = json_encode($content); - $this->isService=false; - $res= $this->request('/pay/micropay', 'POST', ['sign_body' => $content]); + $content['out_trade_no']= $order['order_sn']; + ksort($content); // 按照键名排序 + $sign_str = urldecode(http_build_query($content)); // 构造签名字符串 + $sign = strtoupper(md5($sign_str . '&key=' . 'FC685E79840793CE86AE621CE9EDFCDA')); // 生成签名 + $content['sign']=$sign; + $this->isService = false; + $res = $this->request('/pay/micropay', 'POST', ['sign_body' => $this->arrayToXml($content)]); return $res; } - + function arrayToXml($arr) + { + $xml = ""; + foreach ($arr as $key => $val) { + $xml .= "<" . $key . ">" . $val . ""; + } + $xml .= ""; + return $xml; + } } diff --git a/route/admin/system.php b/route/admin/system.php index 25697eb9..a1ab53a3 100644 --- a/route/admin/system.php +++ b/route/admin/system.php @@ -186,8 +186,29 @@ Route::group(function () { '_auth' => true, ]); - Route::group(function () { + // APP版本管理 + Route::group('app/version', function () { + Route::get('lst', '/list')->name('appVersionList')->option([ + '_alias' => 'APP版本列表', + ]); + Route::get('detail/:id', '/detail')->name('appVersionDetail')->option([ + '_alias' => 'APP版本详情', + ]); + Route::post('create', '/create')->name('appVersionAdd')->option([ + '_alias' => '新增APP版本', + ]); + Route::post('edit/:id', '/update')->name('appVersionEdit')->option([ + '_alias' => '编辑APP版本', + ]); + Route::post('delete/:id', '/delete')->name('appVersionEdit')->option([ + '_alias' => '删除APP版本', + ]); + })->prefix('admin.system.Lhapp')->option([ + '_path' => '/app/version', + '_auth' => true, + ]); + Route::group(function () { Route::get('menus', 'admin.system.auth.Menu/menus'); Route::get('system/city/lst', 'merchant.store.shipping.City/lst'); //退出登陆 diff --git a/route/api.php b/route/api.php index 479268ff..5c7d8403 100644 --- a/route/api.php +++ b/route/api.php @@ -24,6 +24,7 @@ Route::group('api/', function () { Route::any('ceshi', 'api.Demo/ceshi'); Route::any('promote_writing', 'api.Common/promote_writing'); Route::any('applet', 'api.Common/applet'); + Route::get('label_lst', 'api.Common/label_lst'); Route::any('promote_writing', 'api.Common/promoteWriting'); Route::get('business/agree', 'api.Auth/businessAgree'); Route::any('system_group_value', 'api.Common/system_group_value');