Merge pull request 'preview' (#56) from preview into master

Reviewed-on: #56
This commit is contained in:
mkm 2023-10-28 16:10:46 +08:00
commit d6605865c3
132 changed files with 435 additions and 274 deletions

View File

@ -78,7 +78,7 @@ class StoreCartDao extends BaseDao
$query->field('product_id,stock,price,unique,sku,image,svip_price');
},
'merchant' => function ($query) {
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id')->with(['type_name']);
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy')->with(['type_name']);
}
])->select();

View File

@ -55,7 +55,7 @@ class MerchantTypeDao extends BaseDao
[
'type' => 'div',
'children' => [
'保证金:' . $item['margin']. ' 元'
'金:' . $item['margin']. ' 元'
],
'style' => [
'paddingTop' => '100px',

View File

@ -192,11 +192,11 @@ class UserBillDao extends BaseDao
return UserBill::getDB()
->when(isset($where['now_money']) && in_array($where['now_money'], [0, 1, 2]), function ($query) use ($where) {
if ($where['now_money'] == 0)
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'recharge', 'sys_inc_money', 'sys_dec_money', 'brokerage', 'presell', 'refund']);
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'recharge', 'sys_inc_money', 'sys_dec_money', 'brokerage', 'presell', 'refund', 'zhibo_reward_inc', 'zhibo_reward_dec']);
else if ($where['now_money'] == 1)
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'sys_dec_money', 'presell']);
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'sys_dec_money', 'presell', 'zhibo_reward_dec']);
else if ($where['now_money'] == 2)
$query->where('category', 'now_money')->whereIn('type', ['recharge', 'sys_inc_money', 'brokerage', 'refund']);
$query->where('category', 'now_money')->whereIn('type', ['recharge', 'sys_inc_money', 'brokerage', 'refund', 'zhibo_reward_inc']);
})
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
$query->where('uid', $where['uid'])->where('mer_id', 0);

View File

@ -623,39 +623,40 @@ class CommunityRepository extends BaseRepository
$resale->update($value);
continue;
}
$purchaseRecord = PurchaseRecord::where('unique', $value['product_attr_unique'])->find();
// $purchaseRecord = PurchaseRecord::where('unique', $value['product_attr_unique'])->find();
// $exist = Resale::where('purchase_record_id', $purchaseRecord['id'])->find();
// if ($exist) {
// throw new ValidateException('已发起转售');
// }
$totalNumber = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('number');
$totalSalesVolume = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('sales_volume');
if (empty($purchaseRecord) || ($totalNumber - $totalSalesVolume) <= 0) {
throw new ValidateException('进货记录不存在或已售罄');
}
if (($totalNumber - $totalSalesVolume) < $value['number']) {
throw new ValidateException('库存不足');
}
// $totalNumber = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('number');
// $totalSalesVolume = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('sales_volume');
// if (empty($purchaseRecord) || ($totalNumber - $totalSalesVolume) <= 0) {
// throw new ValidateException('进货记录不存在或已售罄');
// }
// if (($totalNumber - $totalSalesVolume) < $value['number']) {
// throw new ValidateException('库存不足');
// }
if ($value) {
$insert[] = [
'community_id' => $id,
'purchase_record_id' => $purchaseRecord['id'],
'product_id' => $purchaseRecord['product_id'],
'product_attr_unique' => $purchaseRecord['unique'],
'mer_id' => $purchaseRecord['mer_id'],
'number' => $value['number'],
'price' => $value['price'],
'resale_type' => $resaleType,
'deliver_method' => $value['deliver_method'] ?? '',
'update_time' => date('Y-m-d H:i:s'),
];
$attrValue = ProductAttrValue::where('unique', $value['product_attr_unique'])->find();
if($attrValue){
$insert[] = [
'community_id' => $id,
'purchase_record_id' => 0,
'product_id' => $attrValue['product_id'],
'product_attr_unique' => $attrValue['unique'],
'mer_id' => $attrValue['mer_id'],
'number' => $value['number'],
'price' => $value['price'],
'resale_type' => $resaleType,
'deliver_method' => $value['deliver_method'] ?? '',
'update_time' => date('Y-m-d H:i:s'),
];
$attrValue->stock -= $value['number'];
$attrValue->save();
}
}
$purchaseRecord->product->stock -= $value['number'];
$purchaseRecord->product->save();
$attrValue = ProductAttrValue::where('product_id', $purchaseRecord['product_id'])->where('unique', $purchaseRecord['unique'])->find();
$attrValue->stock -= $value['number'];
$attrValue->save();
}
if ($insert) {
Resale::getInstance()->insertAll($insert);
@ -681,35 +682,39 @@ class CommunityRepository extends BaseRepository
$entrustInfo->update($value);
continue;
}
$purchaseRecord = PurchaseRecord::where('unique', $value['product_attr_unique'])->find();
$totalNumber = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('number');
$totalSalesVolume = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('sales_volume');
if (empty($purchaseRecord) || ($totalNumber - $totalSalesVolume) <= 0) {
throw new ValidateException('进货记录不存在或已售罄');
}
if (($totalNumber - $totalSalesVolume) < $value['number']) {
throw new ValidateException('库存不足');
}
// $purchaseRecord = PurchaseRecord::where('unique', $value['product_attr_unique'])->find();
// $totalNumber = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('number');
// $totalSalesVolume = PurchaseRecord::where('unique', $value['product_attr_unique'])->sum('sales_volume');
// if (empty($purchaseRecord) || ($totalNumber - $totalSalesVolume) <= 0) {
// throw new ValidateException('进货记录不存在或已售罄');
// }
// if (($totalNumber - $totalSalesVolume) < $value['number']) {
// throw new ValidateException('库存不足');
// }
if ($value) {
$insert[] = [
'community_id' => $id,
'purchase_record_id' => $purchaseRecord['id'],
'product_id' => $purchaseRecord['product_id'],
'product_attr_unique' => $purchaseRecord['unique'],
'mer_id' => $purchaseRecord['mer_id'],
'entrust_mer_id' => $entrustMerId,
'entrust_day' => $entrustDay,
'number' => $value['number'],
'price' => $value['price'],
'update_time' => date('Y-m-d H:i:s'),
];
$attrValue = ProductAttrValue::where('unique', $value['product_attr_unique'])->find();
if($attrValue){
$insert[] = [
'community_id' => $id,
'purchase_record_id' => 0,//$purchaseRecord['id'],
'product_id' => $attrValue['product_id'],
'product_attr_unique' => $attrValue['unique'],
'mer_id' => $attrValue['mer_id'],
'entrust_mer_id' => $entrustMerId,
'entrust_day' => $entrustDay,
'number' => $value['number'],
'price' => $value['price'],
'update_time' => date('Y-m-d H:i:s'),
];
$attrValue->stock -= $value['number'];
$attrValue->save();
}
}
$purchaseRecord->product->stock -= $value['number'];
$purchaseRecord->product->save();
$attrValue = ProductAttrValue::where('product_id', $purchaseRecord['product_id'])->where('unique', $purchaseRecord['unique'])->find();
$attrValue->stock -= $value['number'];
$attrValue->save();
// $purchaseRecord->product->stock -= $value['number'];
// $purchaseRecord->product->save();
}
if ($insert) {
Entrust::getInstance()->insertAll($insert);

View File

@ -375,7 +375,7 @@ class StoreOrderRepository extends BaseRepository
'financial_record_sn' => $financeSn . ($i++)
];
}
//保证金计算
//金计算
if ($_payPrice > 0) {
/** @var MerchantRepository $merchantRepo */
$merchantRepo = app()->make(MerchantRepository::class);

View File

@ -2325,23 +2325,65 @@ class ProductRepository extends BaseRepository
*/
public function stockIn($merId, $params)
{
/**感觉有问题 最好在优化一下结构 */
Db::startTrans();
try {
$supplierMerId = 0;
$model = new PurchaseRecord();
if (empty($params['product_id']) && !empty($params['order_product_id'])) {
//有商品无规格或者无商品无规格,导入商品和规格
$product = $this->getWhere(['source_product_id' => $params['order_product_id'], 'mer_id' => $merId]);
$sku = ProductAttrValue::where('product_id', $params['order_product_id'])->where('unique', $params['order_unique'])->value('sku');
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $product['product_id'])->where('sku', $sku)->find();
if (!empty($product)) {
$unique = $this->importAttrValue($params['order_product_id'], $product->toArray(), $params['order_unique']);
if (!$unique) {
throw new \Exception('商品规格导入出错', 500);
$stockIn = $params['number'] ?? 0;
$price = $params['price'] ?? 0;
if (!empty($params['order_id'])) {
//采购、委托订单导入
$orderMerId = StoreOrder::where('order_id', $params['order_id'])->value('mer_id');
$orderProduct = StoreOrderProduct::where('order_id', $params['order_id'])->where('product_id', $params['order_product_id'])->where('product_sku', $params['order_unique'])->find();
if (empty($orderProduct)) {
$unique = $this->importAttrValue($params['order_product_id'], $product->toArray(), $params['order_unique']);
if (!$unique) {
throw new \Exception('商品规格导入出错', 500);
}
}
if( $orderProduct->is_imported == 1){
if($stockIn==0){
$stockIn=1;
}
ProductAttrValue::where('mer_id', $merId)
->where('product_id', $product['product_id'])
->update(['stock'=>$attrValue->stock + $stockIn]);
$data = [
'order_id' => $params['order_id'] ?? 0,
'order_product_id' => $params['order_product_id'] ?? 0,
'product_id' => $product->product_id,
'number' => $stockIn,
'order_unique' => $params['order_unique'] ?? '',
'unique' => $attrValue['unique'],
'price' => $price,
'mer_id' => $product->mer_id,
'supplier_mer_id' => $orderMerId??0,
];
if (!$model->save($data)) {
throw new \Exception('入库失败', 500);
}
Db::commit();
return true;
}
$stockIn = $orderProduct['product_num'] ?? 0;
$price = $orderProduct['product_price'] ?? 0;
$supplierMerId = $orderMerId ?? 0;
// 如果是委托商品入库后就成为供应链商家的采购类型商品
if ($orderProduct['product_type'] == 99) {
$product->product_type = 98;
}
}
} else {
$productId = $this->import($params['order_product_id'], request()->userInfo());
$product = $this->get($productId);
}
$sku = ProductAttrValue::where('product_id', $params['order_product_id'])->where('unique', $params['order_unique'])->value('sku');
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $product['product_id'])->where('sku', $sku)->find();
} else {
//有商品有规格
$product = $this->get($params['product_id']);
@ -2350,23 +2392,6 @@ class ProductRepository extends BaseRepository
if (!$product || !$attrValue) {
throw new DataNotFoundException('商品或规格不存在');
}
$stockIn = $params['number'] ?? 0;
$price = $params['price'] ?? 0;
if (!empty($params['order_id'])) {
//采购、委托订单导入
$orderMerId = StoreOrder::where('order_id', $params['order_id'])->value('mer_id');
$orderProduct = StoreOrderProduct::where('order_id', $params['order_id'])->where('product_id', $params['order_product_id'])->where('product_sku', $params['order_unique'])->find();
if (empty($orderProduct) || $orderProduct->is_imported == 1) {
throw new ValidateException('订单商品不存在或已入库');
}
$stockIn = $orderProduct['product_num'] ?? 0;
$price = $orderProduct['product_price'] ?? 0;
$supplierMerId = $orderMerId ?? 0;
// 如果是委托商品入库后就成为供应链商家的采购类型商品
if ($orderProduct['product_type'] == 99) {
$product->product_type = 98;
}
}
if ($stockIn <= 0) {
throw new ValidateException('入库数量不能小于等于0');
}
@ -2376,7 +2401,6 @@ class ProductRepository extends BaseRepository
if (!$product->save()) {
throw new \Exception('商品库存保存失败', 500);
}
$model = new PurchaseRecord();
$data = [
'order_id' => $params['order_id'] ?? 0,
'order_product_id' => $params['order_product_id'] ?? 0,

View File

@ -202,7 +202,6 @@ class SpuRepository extends BaseRepository
}
$where['product_id'] = $randPidList;
unset($where['mer_rand_id'], $where['page']);
$page = 1;
}
$entryMerId = $where['entry_mer_id'] ?? '';
unset($where['entry_mer_id']);

View File

@ -318,7 +318,7 @@ class FinancialRepository extends BaseRepository
if ($res['is_margin'] == -1) throw new ValidateException('请勿重复申请');
if (!in_array($res['is_margin'],[10,-10]) || $res['paid_margin'] <= 0)
throw new ValidateException('无可退保证金');
throw new ValidateException('无可退金');
$order = app()->make(ServeOrderRepository::class)->getWhere([
'mer_id' => $res['mer_id'],
@ -327,7 +327,7 @@ class FinancialRepository extends BaseRepository
]);
if (!$order) throw new ValidateException('未查询到支付订单');
$financial_account = [
'name' => '保证金退款',
'name' => '金退款',
'order_id' => $order['order_id'],
'order_sn' => $order['order_sn'],
'pay_price'=> $order['pay_price'],
@ -471,7 +471,7 @@ class FinancialRepository extends BaseRepository
Elm::input('mer_name','商户名称', $data['merchant']->mer_name)->disabled(true),
Elm::input('mer_id','商户ID', $data['mer_id'])->disabled(true),
Elm::input('type_name','店铺类型', $data['merchant']->merchantType->type_name)->disabled(true),
Elm::input('pay_price','保证金额度', $data['merchant']->marginOrder->pay_price)->disabled(true),
Elm::input('pay_price','金额度', $data['merchant']->marginOrder->pay_price)->disabled(true),
Elm::input('sub','扣费金额', bcsub($data['merchant']->marginOrder->pay_price, $data['extract_money'], 2))->disabled(true),
Elm::input('refund','退回金额', $data['extract_money'])->disabled(true),
Elm::radio('status', '审核', -1)->setOptions([
@ -485,7 +485,7 @@ class FinancialRepository extends BaseRepository
]
],])
]);
return $form->setTitle('退保证金审核');
return $form->setTitle('退金审核');
}
/**
@ -647,7 +647,7 @@ class FinancialRepository extends BaseRepository
}
/**
* TODO 同意退保证
* TODO 同意退
* @param $res
* @author Qinii
* @day 1/27/22
@ -657,10 +657,10 @@ class FinancialRepository extends BaseRepository
//验证
$comp = bccomp($res['financial_account']->pay_price, $res['extract_money'], 2);
if ($comp == -1)
throw new ValidateException('申请退款金额:'.$res['extract_money'].',大于支付保证金:'.$res['financial_account']->pay_price);
throw new ValidateException('申请退款金额:'.$res['extract_money'].',大于支付金:'.$res['financial_account']->pay_price);
// if (bccomp($res['merchant']['margin'], $res['extract_money'],2) == -1)
// throw new ValidateException('申请退款金额:'.$res['extract_money'].',大于剩余保证金:'.$res['merchant']['margin']);
// throw new ValidateException('申请退款金额:'.$res['extract_money'].',大于剩余金:'.$res['merchant']['margin']);
Db::transaction(function () use ($res){
//退款

View File

@ -254,7 +254,7 @@ class FinancialRecordRepository extends BaseRepository
{
//商户收入
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell'])->sum('number');
//保证
//
$auto_margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number');
$auto_margin_refund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number');
//平台优惠券
@ -330,7 +330,7 @@ class FinancialRecordRepository extends BaseRepository
'className' => 'el-icon-s-cooperation',
'count' => bcsub($auto_margin,$auto_margin_refund,2),
'field' => '元',
'name' => '商户保证金金额'
'name' => '商户金金额'
],
];
return compact('stat');
@ -490,7 +490,7 @@ class FinancialRecordRepository extends BaseRepository
bcsub($expend['count_order_charge'], $expend['count_charge']). '笔',
],
[
'店铺保证金',
'店铺金',
$expend['number_auto_margin'] . '元',
$expend['count_auto_margin'] . '笔'
@ -674,10 +674,10 @@ class FinancialRecordRepository extends BaseRepository
$financialType = ['order_charge', 'presell_charge'];
[$data['count_order_charge'], $data['number_order_charge']] = $this->dao->getDataByType($type, $where, $date, $financialType);
//商户保证
//商户
$financialType = ['auto_margin'];
[$data['count_auto_margin'], $data['number_auto_margin']] = $this->dao->getDataByType($type, $where, $date, $financialType);
//商户保证金退回
//商户金退回
$financialType = ['auto_margin_refund'];
[$data['count_auto_margin_refund'], $data['number_auto_margin_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$number3 = bcsub($data['number_auto_margin'], $data['number_auto_margin_refund'], 2);

View File

@ -137,7 +137,7 @@ class MerchantIntentionRepository extends BaseRepository
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
'mer_password' => $password,
'is_margin' => $margin['is_margin'] ?? -1,
// 用户需缴纳保证
// 用户需缴纳
'margin' => $margin['margin'] ?? 0,
'uid' => $intention['uid'],
'reg_admin_id' => $autoCreate ? 0: request()->adminId(),

View File

@ -66,14 +66,14 @@ use think\Model;
class MerchantRepository extends BaseRepository
{
const WithoutMargin = 0; //不需要保证
const NeedMargin = 1; //需要保证
const PaidMargin = 10; //已支付保证
const RefundMargin = -1; //申请退还保证
const RefuseMargin = -10; //拒绝退还保证
const WithoutMargin = 0; //不需要
const NeedMargin = 1; //需要
const PaidMargin = 10; //已支付
const RefundMargin = -1; //申请退还
const RefuseMargin = -10; //拒绝退还
public $merId;
public $forceMargin = false; //强制扣除保证
public $forceMargin = false; //强制扣除
/**
* MerchantRepository constructor.
@ -622,17 +622,17 @@ class MerchantRepository extends BaseRepository
{
$merchant = $this->dao->get($id);
if ($merchant->is_margin !== 10) {
throw new ValidateException('商户无保证金可扣');
throw new ValidateException('商户无金可扣');
}
$form = Elm::createForm(Route::buildUrl('systemMarginSet')->build());
$form->setRule([
Elm::input('mer_name', '商户名称', $merchant->mer_name)->disabled(true),
Elm::input('mer_id', '商户ID', $merchant->mer_id)->disabled(true),
Elm::input('margin', '商户剩余保证金', $merchant->paid_margin)->disabled(true),
Elm::number('number', '保证金扣除金额', 0)->max($merchant->paid_margin)->precision(2)->required(),
Elm::text('mark', '保证金扣除原因')->required(),
Elm::input('margin', '商户剩余金', $merchant->paid_margin)->disabled(true),
Elm::number('number', '金扣除金额', 0)->max($merchant->paid_margin)->precision(2)->required(),
Elm::text('mark', '金扣除原因')->required(),
]);
return $form->setTitle('扣除保证金');
return $form->setTitle('扣除金');
}
/**
@ -646,14 +646,14 @@ class MerchantRepository extends BaseRepository
{
$merechant = $this->dao->get($data['mer_id']);
if ($merechant->is_margin !== 10) {
throw new ValidateException('商户未支付保证金或已申请退款');
throw new ValidateException('商户未支付金或已申请退款');
}
if ($data['number'] < 0) {
throw new ValidateException('扣除保证金额不能小于0');
throw new ValidateException('扣除金额不能小于0');
}
if (bccomp($merechant->paid_margin, $data['number'], 2) == -1) {
throw new ValidateException('扣除保证金额不足');
throw new ValidateException('扣除金额不足');
}
$data['balance'] = bcsub($merechant->paid_margin, $data['number'], 2);
@ -679,7 +679,7 @@ class MerchantRepository extends BaseRepository
}
/**
* 自动扣除保证
* 自动扣除
* @param $income
* @param $order
* @param $finance
@ -691,12 +691,12 @@ class MerchantRepository extends BaseRepository
{
$merchant = Merchant::find($this->merId);
$margin_type = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');
//商户保证金大于支付保证金 或者forceMargin==false 直接返回 不计算保证
//商户押金大于支付押金 或者forceMargin==false 直接返回 不计算押
if ($merchant['paid_margin']>= $margin_type|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) {
return [$income, $finance, false];
}
$rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate'];
// //商户保证金未完全缴纳且设置了自动扣除比例
// //商户金未完全缴纳且设置了自动扣除比例
$margin= bcmul($income, bcdiv($rate, 100,2), 2);
// $margin = min(bcsub($margin, $merchant['paid_margin'], 2), $margin);
// $income = max(bcsub($income, $margin, 2), 0);

View File

@ -124,7 +124,7 @@ class MerchantTypeRepository extends BaseRepository
$make = app()->make(RelevanceRepository::class);
$make->batchDelete($id, RelevanceRepository::TYPE_MERCHANT_AUTH);
$make->insertAll($inserts);
//更新未交保证金的商户
//更新未交金的商户
app()->make(MerchantRepository::class)->updateMargin($id, $data['margin'], $data['is_margin']);
});
}

View File

@ -38,7 +38,7 @@ class ServeOrderRepository extends BaseRepository
const TYPE_COPY_PRODUCT = 1;
//电子面单
const TYPE_DUMP = 2;
//保证金 margin
//金 margin
const TYPE_MARGIN = 10;
//同城配送delivery
const TYPE_DELIVERY = 20;
@ -83,7 +83,7 @@ class ServeOrderRepository extends BaseRepository
}
/**
* TODO 商户保证支付
* TODO 商户支付
* @param $merId
* @param $data
* @return array
@ -93,7 +93,7 @@ class ServeOrderRepository extends BaseRepository
public function margin($merId, $data)
{
$ret = app()->make(MerchantRepository::class)->get($merId);
if ($ret['is_margin'] !== 1) throw new ValidateException('此商户无需支付保证金');
if ($ret['is_margin'] !== 1) throw new ValidateException('此商户无需支付金');
$key = 'Margin_'.$merId.'_'.date('YmdH',time());
$arr = [
'type_id' => $ret['type_id'],

View File

@ -67,11 +67,11 @@ class MerchantMargin extends BaseController
public function setMargin()
{
$data = $this->request->params(['mer_id','number',['type','mer_margin'],'mark']);
$data['title'] = '保证金扣除';
$data['title'] = '金扣除';
if ($data['number'] < 0)
return app('json')->fail('扣除金额不能小于0');
app()->make(MerchantRepository::class)->setMargin($data);
return app('json')->success('扣除保证金成功');
return app('json')->success('扣除金成功');
}
}

View File

@ -95,7 +95,7 @@ class MerchantType extends BaseController
$validate = app()->make(MerchantTypeValidate::class);
$validate->check($data);
if ($data['is_margin'] == 1) {
if ($data['margin'] <= 0) throw new ValidateException('保证金必须大于0');
if ($data['margin'] <= 0) throw new ValidateException('金必须大于0');
} else {
$data['margin'] = 0;
}

View File

@ -57,7 +57,7 @@ use app\common\service\TopClient;
use app\controller\api\Ceshi;
use taobao\request\TbkItemInfoGetRequest;
use app\common\repositories\store\product\ProductRepository;
use crmeb\services\UploadService;
use think\facade\App;
/**
* Class Auth
@ -69,33 +69,36 @@ class Auth extends BaseController
{
public function caiji()
{
$url=$this->request->host();
$parmas = $this->request->param();
$query = parse_url($parmas['url']);
$itemId = $this->convertUrlQuery($query['query']);
$query=parse_url($parmas['url']);
$itemId=$this->convertUrlQuery($query['query']);
$c = new TopClient;
$c->appkey = '34537213';
$c->secretKey = '4a35f3657156580c1f533750295c54c4';
$req = new TbkItemInfoGetRequest;
$req->setNumIids($itemId['itemId']);
$resp = $c->execute($req);
$res = $resp->results->n_tbk_item;
$arr = json_decode(json_encode($res), true);
$images = [];
$upload = UploadService::create();
$dir = 'def/' . date('Y-m-d');
$oss = $upload->to($dir)->stream(file_get_contents($arr['pict_url']));
$pict_url = $oss->filePath;
foreach ($arr['small_images']['string'] as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$images[] = $oss->filePath;
$res=$resp->results->n_tbk_item;
$images=[];
$filename = basename($res->pict_url); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
$pict_url= $url.'/uploads/img/'.$filename;
file_put_contents($destination, file_get_contents($res->pict_url));
if($resp && isset($resp->small_images) && isset($resp->small_images->string)){
foreach($resp->small_images->string as $k=>$v){
$filename = basename($v); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
file_put_contents($destination, file_get_contents($v));
$images[]=$url.'/uploads/img/'.$filename;
}
}
$data = [
$data=[
"image" => $pict_url,
"slider_image" => $images,
"store_name" => $arr['title'],
"store_info" => $arr['cat_leaf_name'],
"slider_image" =>$images,
"store_name" => json_decode(json_encode($res->title),true)[0],
"store_info" => json_decode(json_encode($res->cat_leaf_name),true)[0],
"keyword" => "",
"bar_code" => "",
"guarantee_template_id" => "",
@ -115,8 +118,8 @@ class Auth extends BaseController
"attr" => [],
"mer_labels" => [],
"delivery_way" => [
0 => "1",
1 => "2"
0 => "1",
1 => "2"
],
"delivery_free" => 0,
"param_temp_id" => [],
@ -128,17 +131,17 @@ class Auth extends BaseController
"once_min_count" => 0,
"pay_limit" => 0,
"attrValue" => [
0 => [
"image" => $pict_url,
"price" => bcsub($arr['reserve_price'], ($arr['reserve_price'] * 0.05), 2),
"cost" => 0,
"ot_price" => 0,
"svip_price" => null,
"stock" => 100,
"bar_code" => "",
"weight" => 0,
"volume" => 0,
],
0 => [
"image" => $pict_url,
"price" => bcsub($res->reserve_price,($res->reserve_price*0.05),2),
"cost" => 0,
"ot_price" => 0,
"svip_price" => null,
"stock" => 100,
"bar_code" => "",
"weight" => 0,
"volume" => 0,
],
],
"give_coupon_ids" => [],
"type" => 0,
@ -149,22 +152,22 @@ class Auth extends BaseController
"status" => 0,
"mer_status" => 1,
"rate" => 3,
];
$a = app()->make(ProductRepository::class)->create($data, 0, 1);
];
$a= app()->make( ProductRepository::class)->create($data,0,1);
// 下载图片并保存到目标路径
return app('json')->success($a);
}
function convertUrlQuery($query)
{
$queryParts = explode('&', $query);
$params = array();
foreach ($queryParts as $param) {
$item = explode('=', $param);
$params[$item[0]] = $item[1];
}
return $params;
$queryParts = explode('&', $query);
$params = array();
foreach ($queryParts as $param) {
$item = explode('=', $param);
$params[$item[0]] = $item[1];
}
return $params;
}
public function dotest()
{
@ -382,13 +385,14 @@ class Auth extends BaseController
public function doMargin()
{
return app('json')->fail('线上缴纳调整中,请在线下缴纳');
$user = $this->request->userInfo();
$merchant = Db::name('merchant')->where('uid', $user['uid'])->where('status', 1)->find();
if (!$merchant) {
return app('json')->fail('没有店铺');
}
if ($merchant['is_margin'] == 10) {
return app('json')->fail('保证金已缴纳');
return app('json')->fail('金已缴纳');
}
if ($merchant['margin'] == 0) {
$margin = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');

View File

@ -186,9 +186,6 @@ class Statistics extends BaseController
if (!isset($parmas['end_time']) || $parmas['end_time'] == '') {
return app('json')->fail('end_time:格式错误');
}
if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') {
return app('json')->fail('mer_intention_id:格式错误');
}
if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') {
return app('json')->fail('goods_id:格式错误');
}
@ -197,17 +194,16 @@ class Statistics extends BaseController
}else{
return app('json')->fail('responsible_area:格式错误');
}
$merchant=Db::name('merchant')->where('street_id','in',$area)->select();
$merchant=Db::name('merchant')->where($area)->column('mer_id');
if(!$merchant){
return app('json')->fail('responsible_area:格式错误');
return app('json')->fail('查询商户为空');
}
$where[]=['p.create_time','between time',[date("Y-m-d H:i:s",$parmas['start_time']),date("Y-m-d H:i:s",$parmas['end_time'])]];
$where[] = ['p.product_id','in',explode(',', $parmas['goods_id'])];
$where[] = ['p.is_refund','=',0];
$count=Db::name('store_order_product')->alias('p')
->where($where)
->join('store_order o','o.mer_id in '.$parmas['mer_intention_id'].' and o.paid=1 and o.is_del=0')
->join('store_order o','o.mer_id in ('.implode(',',$merchant).') and o.paid=1 and o.is_del=0')
->sum('p.total_price');
return app('json')->success(['procure_amount'=>$count]);
}

View File

@ -800,13 +800,17 @@ class Community extends BaseController
if (!$communityInfo) {
return app('json')->fail('委托商品不存在');
}
$uid = $this->request->uid();
$communityInfo['mer_info'] = Db::name('merchant')->where('uid', $uid)->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar', 'settle_cycle', 'interest_rate'])->find();
// $uid = $this->request->uid();
$entrust = Db::name('entrust')->where('community_id', $id)->find();
if (!$entrust) {
return app('json')->fail('委托商品不存在');
}
$entrustDay=$entrust['entrust_day'];
$communityInfo['mer_info'] = Db::name('merchant')->where('mer_id', $entrust['mer_id'])->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar', 'settle_cycle', 'interest_rate'])->find();
$communityInfo['entrust_mer_info'] = Db::name('merchant')->where('mer_id', $communityInfo['entrust_mer_id'])->where('is_del', 0)->field(['mer_id', 'mer_name', 'mer_address', 'mer_avatar'])->find();
if (empty($communityInfo['mer_info']) || empty($communityInfo['entrust_mer_info'])) {
return app('json')->fail('无权限查看委托商品');
}
$entrustDay = Db::name('entrust')->where('community_id', $id)->where('is_del', 0)->value('entrust_day');
$communityInfo['entrust_day'] = $entrustDay;
$communityInfo['product_list'] = Db::name('entrust')->alias('e')->leftJoin('store_product sp','e.product_id = sp.product_id')->leftJoin('store_product_attr_value spav','spav.unique = e.product_attr_unique')->where('e.community_id', $id)->where('sp.is_del', 0)->setOption('field', [])->field(['e.product_id, e.product_attr_unique, e.number, e.price, e.status, spav.price as old_price, sp.store_name, sp.image'])->select();
if ($communityInfo['product_list']) $communityInfo['product_list'] = $communityInfo['product_list']->toArray();

View File

@ -215,7 +215,7 @@ class Merchant extends BaseController
$data = $this->request->params(['mer_state']);
if ($merchant['is_margin'] == 1 && $data['mer_state'] == 1)
return app('json')->fail('开启店铺前请先支付保证金');
return app('json')->fail('开启店铺前请先支付金');
if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine'))
return app('json')->fail('开启店铺前请先完成微信子商户入驻');

View File

@ -195,7 +195,7 @@ class MerchantIntention extends BaseController
'city' => $areaInfo['city_code'] ?? '',
'area' => $merInfo['area_id'] ?? '',
'street' => $merInfo['street_id'] ?? '',
'address' => $merInfo['address'] ?? '',
'address' => $intenInfo['address'] ?? '',
'bank_username' => $data['bank_username'] ?? '',
'bank_opening' => $data['bank_opening'] ?? '',
'bank_front' => $data['bank_front'] ?? '',

View File

@ -0,0 +1,132 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\api\user;
use crmeb\basic\BaseController;
use app\common\repositories\user\UserBillRepository;
use think\App;
use think\exception\HttpResponseException;
use think\exception\ValidateException;
use think\facade\Db;
use think\response\Json;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
/**
* Class Auth
* @package app\controller\api
* @author xaboy
* @day 2020-05-06
*/
class Zhibo extends BaseController
{
//用户直播送礼
public function reward()
{
$user = $this->request->userInfo();
$params = $this->request->params(['live_stream_id', 'master_id', 'live_name', 'gift_id', 'gift_name', 'gift_num', 'amount']);
if (empty($params['live_stream_id']) || empty($params['master_id']) || empty($params['gift_id']) || empty($params['live_name']) || empty($params['gift_name']) || empty($params['amount'])) {
return app('json')->fail('live_stream_id, master_id, live_name, gift_id, gift_name, gift_num, amount 参数不能为空');
}
if ($params['amount'] > $user['now_money']) {
return app('json')->fail('余额不足');
}
try {
Db::transaction(function () use ($user, $params) {
//打赏订单
$orderId = Db::name('user_zhibo_order')->insertGetId([
'live_stream_id' => $params['live_stream_id'],
'live_name' => $params['live_name'],
'gift_id' => $params['gift_id'],
'gift_name' => $params['gift_name'],
'gift_num' => $params['gift_num'],
'uid' => $user['uid'],
'master_id' => $params['master_id'],
'order_sn' => 'zb' . date('YmdHis') . mt_rand(1000, 9999),
'amount' => $params['amount'],
'pay_status' => 1,
'pay_time' => date('Y-m-d H:i:s'),
'create_time' => date('Y-m-d H:i:s'),
'update_time' => date('Y-m-d H:i:s'),
]);
//打赏人扣钱
$user->now_money = bcsub($user['now_money'], $params['amount']);
$user->save();
$userBillRepository = app()->make(UserBillRepository::class);
//打赏人账单
$userBillRepository->decBill($user['uid'], 'now_money', 'zhibo_reward_dec', [
'link_id' => $orderId,
'status' => 1,
'title' => '直播送礼支出',
'number' => $params['amount'],
'mark' => '余额送礼',
'balance' => $user->now_money
]);
//主播加钱
Db::name('user')->where('uid', $params['master_id'])->inc('now_money', $params['amount'])->update();
$master = Db::name('user')->where('uid', $params['master_id'])->find();
//主播账单
$userBillRepository->incBill($master['uid'], 'now_money', 'zhibo_reward_inc', [
'link_id' => $orderId,
'status' => 1,
'title' => '直播送礼收入',
'number' => $params['amount'],
'mark' => '直播送礼收入',
'balance' => $master['now_money']
]);
});
} catch (Exception $e) {
return app('json')->fail($e->getMessage());
}
return app('json')->success('送礼成功');
}
//用户送礼收礼记录
public function rewardList()
{
[$page, $limit] = $this->getPage();
$token = request()->header('x-token');
$params = $this->request->params(['type']);
if (empty($params['type'])) {
return app('json')->fail('类型不能为空');
}
$user = $this->request->userInfo();
$where = [];
if ($params['type'] == 1) {
// 送出的礼物
$where['ub.pm'] = 0;
$where['ub.type'] = 'zhibo_reward';
$where['uzo.uid'] = $user['uid'];
} elseif ($params['type'] == 2){
// 收到的礼物
$where['ub.pm'] = 1;
$where['ub.type'] = 'zhibo_reward';
$where['uzo.master_id'] = $user['uid'];
} else {
return app('json')->fail('类型错误');
}
$count = Db::name('user_bill')->alias('ub')->leftJoin('user_zhibo_order uzo','uzo.order_id = ub.link_id')->where($where)->count();
$list = Db::name('user_bill')->alias('ub')->leftJoin('user_zhibo_order uzo','uzo.order_id = ub.link_id')->where($where)->limit(($page-1) * $limit, $limit)->field([
'uzo.order_id',
'uzo.live_stream_id',
'uzo.live_name',
'uzo.gift_id',
'uzo.gift_name',
'uzo.order_sn',
'uzo.amount',
'ub.title',
'uzo.create_time'
])->select();
return app('json')->success(compact('count', 'list'));
}
}

View File

@ -122,7 +122,7 @@ class Merchant extends BaseController
$data = $this->request->params(['mer_state']);
if ($merchant->is_margin == 1 && $data['mer_state'] == 1)
return app('json')->fail('开启店铺前请先支付保证金');
return app('json')->fail('开启店铺前请先支付金');
if ($data['mer_state'] && !$merchant->sub_mchid && systemConfig('open_wx_combine'))
return app('json')->fail('开启店铺前请先完成微信子商户入驻');

View File

@ -34,7 +34,7 @@ class AfterRefund
if (in_array($financialRecord['financial_type'], ['commission_to_cloud_warehouse', 'commission_to_entry_merchant', 'commission_to_service_team', 'commission_to_village', 'commission_to_town', ])) {
//佣金类型的退还佣金
if ($financialRecord['financial_type'] == 'commission_to_entry_merchant') {
//入口店铺的佣金,如果有保证金,不退佣金
//入口店铺的佣金,如果有金,不退佣金
$isMargin = $this->isMargin($financialRecords, $financialRecord['mer_id']);
if (!$isMargin) {
$this->subMoney($financialRecord);
@ -49,7 +49,7 @@ class AfterRefund
}
if ($financialRecord['financial_type'] == 'auto_margin') {
Log::info("refundMargin, mer_id: {$financialRecord['mer_id']}, money: {$financialRecord['number']}");
//保证金类型的扣除保证
//押金类型的扣除押
ServeOrder::getInstance()->where('store_order_id', $financialRecord['order_id'])->update(['is_del' => 1]);
$merchant = app()->make(MerchantDao::class)->get($financialRecord['mer_id']);
$merchant->paid_margin = max(bcsub($merchant['paid_margin'], $financialRecord['number'], 2), 0);
@ -65,7 +65,7 @@ class AfterRefund
}
/**
* 是否有保证
* 是否有
* @param $financialRecords
* @param $merId
* @return bool

View File

@ -14,7 +14,7 @@ class paySuccessMargin
public $event;
public function handle($event)
{
Log::info('微信支付保证金成功回调' . json_encode($event));
Log::info('微信支付金成功回调' . json_encode($event));
Db::startTrans();
try {
$order_sn = $event['order_sn'];
@ -27,7 +27,7 @@ class paySuccessMargin
$merchantInfo = Db::name('merchant')->where('mer_id', $marginInfo['mer_id'])->where('uid', $marginInfo['uid'])->find();
$merchant_type = Db::name('merchant_type')->where('mer_type_id', $merchantInfo['type_id'])->find();
//已支付的保证
//已支付的
$paidMarginAmount = bcadd($merchantInfo['paid_margin'], $marginInfo['total_price'], 2);
Db::name('merchant')->where('mer_id', $marginInfo['mer_id'])->where('uid', $marginInfo['uid'])->update([
'paid_margin' => $paidMarginAmount,'ot_margin'=>$paidMarginAmount
@ -45,7 +45,7 @@ class paySuccessMargin
// 提交事务
Db::commit();
} catch (\Exception $e) {
Log::error('微信支付保证金失败' . $e->getMessage());
Log::error('微信支付金失败' . $e->getMessage());
// 回滚事务
Db::rollback();
}

View File

@ -22,9 +22,9 @@ class MerchantTypeValidate extends Validate
protected $rule = [
'type_name|店铺类型名称' => 'require|max:5',
'type_info|店铺类型要求' => 'max:256',
'is_margin|是否有保证金' => 'require|in:0,1',
'is_margin|是否有金' => 'require|in:0,1',
'auth|权限' => 'require|array|min:1',
'margin|保证金(¥)' => 'requireIf:is_margin,1',
'margin|金(¥)' => 'requireIf:is_margin,1',
'description|其他说明' => 'max:256',
];
}

View File

@ -51,8 +51,8 @@ class MerchantValidate extends Validate
'is_bro_room|直播间状态' => 'require|in:0,1',
'is_trader|自营状态' => 'require|in:0,1',
'commission_rate|提成比例' => '>=:0',
'auto_margin_rate|自动扣除保证金比例' => '>=:0',
'paid_margin|已支付的保证金' => '>=:0',
'auto_margin_rate|自动扣除金比例' => '>=:0',
'paid_margin|已支付的金' => '>=:0',
];
/**

View File

@ -62,9 +62,9 @@ return [
'APPLYMENTS_FAIL' => 550523,
//商户申请分账待验证
'APPLYMENTS_SIGN' => 550525,
//商户申请退回保证金通过
//商户申请退回金通过
'REFUND_MARGIN_SUCCESS' => 710327,
//商户申请退回保证金未通过
//商户申请退回金未通过
'REFUND_MARGIN_FAIL' => 710328,
],
//微信

View File

@ -72,9 +72,9 @@ return [
'APPLYMENTS_SIGN' => 550525,
//商户申请分账未通过 2.1
'APPLYMENTS_FAIL' => 550523,
//商户申请退回保证金通过 2.1
//商户申请退回金通过 2.1
'REFUND_MARGIN_SUCCESS' => 710327,
//商户申请退回保证金未通过 2.1
//商户申请退回金未通过 2.1
'REFUND_MARGIN_FAIL' => 710328,
//付费会员充值成功提醒 2.1
'SVIP_PAY_SUCCESS' => 856046
@ -130,9 +130,9 @@ return [
'APPLYMENTS_FAIL' => '',
//商户申请分账待验证
'APPLYMENTS_SIGN' => '',
//商户申请退回保证金通过
//商户申请退回金通过
'REFUND_MARGIN_SUCCESS' => '',
//商户申请退回保证金未通过
//商户申请退回金未通过
'REFUND_MARGIN_FAIL' => '',
],
]

View File

@ -354,7 +354,7 @@ class ExcelService
'order_presell' => '预售订单(定金)',
'refund_platform_coupon' => '退回优惠券补贴',
'order_platform_coupon' => '优惠券补贴',
'auto_margin' => '保证金',
'auto_margin' => '金',
'commission_to_service_team' => '订单平台佣金',
'commission_to_platform' => '订单剩余平台手续费',
'commission_to_village' => '订单平台佣金',
@ -363,7 +363,7 @@ class ExcelService
'commission_to_platform_refund' => '退回剩余平台手续费',
'commission_to_village_refund' => '退回平台佣金',
'commission_to_town_refund' => '退回平台佣金',
'auto_margin_refund' => '退回保证金',
'auto_margin_refund' => '退回金',
'commission_to_entry_merchant' => '订单平台佣金',
'commission_to_cloud_warehouse' => '订单平台佣金',
'commission_to_entry_merchant_refund' => '退回平台佣金',

View File

@ -261,10 +261,10 @@ class SmsService
'site' => systemConfig('site_name'),
]);
break;
//保证金退回申请通过通知 2.1
//金退回申请通过通知 2.1
case 'REFUND_MARGIN_SUCCESS':
//nobreak;
//保证金退回申请未通过通知 2.1
//金退回申请未通过通知 2.1
case 'REFUND_MARGIN_FAIL':
self::create()->send($id['phone'], $tempId, ['name' => $id['name'], 'time' => $id['time'],]);
break;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More