lqmac 7 months ago
parent 7a3f406cea
commit a2b22afafc
  1. 18
      app/api/model/Goods.php
  2. 42
      app/command/SyncStoreBasicData.php
  3. 4
      app/store/model/Express.php
  4. 4
      app/store/model/Order.php

@ -465,8 +465,8 @@ class Goods extends GoodsModel
}
$goodsInfo['merchant'] = null;
//商户信息
//if ($goodsInfo['merchant_id'] && !in_array($goodsInfo['channel'], ['jd','jd1','jd2','sn','sn2','xqtx'])) {
if ($goodsInfo['merchant_id']) {
if ($goodsInfo['merchant_id'] && !in_array($goodsInfo['channel'], ['jd','jd1','jd2','sn','sn2','xqtx'])) {
//if ($goodsInfo['merchant_id']) {
$merchant = \app\common\model\Merchant::detail($goodsInfo['merchant_id'], $goodsInfo->store_id);
if ($merchant) {
if ($merchant['license_img_id']) {
@ -481,6 +481,8 @@ class Goods extends GoodsModel
}
$goodsInfo['merchant'] = $merchant;
} else {
$goodsInfo['merchant_id'] = 0;
}
//加入足迹
$userId = UserService::getCurrentLoginUserId(false) ?? '';
@ -670,7 +672,7 @@ class Goods extends GoodsModel
$catService = new GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价
$goods['discount'] = 0.0;
//$goods['discount'] = 0.0;
//价格判断
if (UserService::isstore()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
@ -680,18 +682,18 @@ class Goods extends GoodsModel
} elseif (UserService::isPlusMember()) {
$membershipPrice = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
$goods['discount'] = bcdiv((string)($membershipPrice * 10), (string)$goods['goods_price_min'], 1);
//$goods['discount'] = bcdiv((string)($membershipPrice * 10), (string)$goods['goods_price_min'], 1);
$goods['goods_price_min'] = $membershipPrice;
} elseif (UserService::isDealerMember()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
$goods['discount'] = bcdiv((string)($priceArr['distributionPrice'] * 10), (string)$goods['goods_price_min'], 1);
//$goods['discount'] = bcdiv((string)($priceArr['distributionPrice'] * 10), (string)$goods['goods_price_min'], 1);
//$goods['goods_price_min'] = $membershipPrice;
$goods['goods_price_min'] = $priceArr['distributionPrice'];
}
if ($goods['discount'] == 10) {
$goods['discount'] = 0.0;
}
// if ($goods['discount'] == 10) {
// $goods['discount'] = 0.0;
// }
// 会员折扣价: 商品sku列表
if ($goods->getRelation('skuList') || $goods->getRelation('skuList1')) {

@ -16,6 +16,7 @@ use app\common\model\Store;
use app\common\model\Agreement;
use app\common\model\UploadFile;
use app\common\model\Banner;
use app\common\model\Express;
use app\store\model\server\RecoveryCategory;
use app\store\model\server\ServerRecovery;
use app\store\model\server\Server;
@ -25,7 +26,7 @@ use app\store\model\Setting;
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test
class SyncStoreBasicData extends Command
{
const DEFAULT_STORE_ID = 10048;
const DEFAULT_STORE_ID = 10045;
protected function configure()
{
@ -39,10 +40,12 @@ class SyncStoreBasicData extends Command
$this->addArgument("isSyncServerData");
$this->addArgument("isSyncBannerData");
$this->addArgument("isSyncStoreSettingData");
$this->addArgument("isSyncStoreExpressData");
}
protected function execute(Input $input, Output $output)
{
exit();
$store_id = $input->getArgument("store_id");
$isSyncMaintenanceData = $input->getArgument("isSyncMaintenanceData");
$isSyncHelpData = $input->getArgument("isSyncHelpData");
@ -51,6 +54,7 @@ class SyncStoreBasicData extends Command
$isSyncServerData = $input->getArgument("isSyncServerData");
$isSyncBannerData = $input->getArgument("isSyncBannerData");
$isSyncStoreSettingData = $input->getArgument("isSyncStoreSettingData");
$isSyncStoreExpressData = $input->getArgument("isSyncStoreExpressData");
$where[] = ['is_sync','=', 0];
$where[] = ['is_delete','=', 0];
@ -92,10 +96,46 @@ class SyncStoreBasicData extends Command
if ($isSyncStoreSettingData) {
$this->syncStoreSettingData($store);
}
if ($isSyncStoreExpressData) {
$this->syncStoreExpressData($store);
}
Store::where('store_id', $store['store_id'])->update(['is_sync' => 1]);
}
}
/**
* 同步物流公司
* [syncStoreExpressData description]
* @param [type] $store [description]
* @return [type] [description]
*/
private function syncStoreExpressData($store){
//维修分类数据同步
$expressList = Express::where('store_id',self::DEFAULT_STORE_ID)->select()->toArray();
if ($expressList) {
foreach ($expressList as &$express) {
$info = Express::where('store_id', $store['store_id'])->where('original_id', $express['express_id'])->find();
if ($info) {
echo $express['express_id']."物流公司已存在".PHP_EOL;
$ret = Express::where('store_id', $store['store_id'])->where('original_id', $express['express_id'])->update([
'express_name' => $express['express_name'],
'kuaidi100_code' => $express['kuaidi100_code'],
'kdniao_code' => $express['kdniao_code'],
]);
var_dump($ret);
continue;
}
$express['create_time'] = time();
$express['update_time'] = time();
$express['original_id'] = $express['express_id'];
$express['store_id'] = $store['store_id'];
unset($express['express_id']);
$ret = Express::create($express);
var_dump($ret->express_id);
}
unset($express);
}
}
/**
* 同步基本信息,七牛云、快递100、99api的配置

@ -13,7 +13,7 @@ declare (strict_types=1);
namespace app\store\model;
use app\common\model\Express as ExpressModel;
use app\store\model\order\Delivery;
/**
* 物流公司模型
* Class Goods
@ -49,7 +49,7 @@ class Express extends ExpressModel
public function remove(): bool
{
// 判断当前物流公司是否已被订单使用
$Order = new Order;
$Order = new Delivery;
if ($orderCount = $Order->where(['express_id' => $this['express_id']])->count()) {
$this->error = '当前物流公司已被' . $orderCount . '个订单使用,不允许删除';
return false;

@ -49,18 +49,16 @@ class Order extends OrderModel
]);
$order->merchant_remark = $order->merchant_remark ? htmlspecialchars_decode($order->merchant_remark) : "";
$goods = $order->goods ? $order->goods->toArray() : [];
if ($goods) {
$goods = array_column($goods, null, 'goods_id');
if ($order->delivery) {
$delivery = $order->delivery->toArray();
foreach ($order->delivery as &$val) {
foreach ($val->goods as &$value) {
$value->goods_name = $goods[$value->goods_id]['goods_name'] ?? "";
$value->goods_image = $goods[$value->goods_id]['goods_image'] ?? "";
}
}
$order->delivery = $delivery;
}
}

Loading…
Cancel
Save