更新
This commit is contained in:
parent
872f27305a
commit
c47567239b
@ -7,7 +7,7 @@ use app\admin\controller\BaseAdminController;
|
|||||||
use app\admin\lists\operation\OpurchaseclassLists;
|
use app\admin\lists\operation\OpurchaseclassLists;
|
||||||
use app\admin\logic\operation\OpurchaseclassLogic;
|
use app\admin\logic\operation\OpurchaseclassLogic;
|
||||||
use app\admin\validate\operation\OpurchaseclassValidate;
|
use app\admin\validate\operation\OpurchaseclassValidate;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购订单控制器
|
* 采购订单控制器
|
||||||
@ -91,5 +91,33 @@ class OpurchaseclassController extends BaseAdminController
|
|||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 推送给供应商报价
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function createSupplierGoods(){
|
||||||
|
$params=$this->request->post();
|
||||||
|
$result = OpurchaseclassLogic::createSupplierGoods($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('推送成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(OpurchaseclassLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置采纳商品
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function goods_offer_update(){
|
||||||
|
$id=$this->request->post('id');
|
||||||
|
$result = OpurchaseclassLogic::goodsOfferUpdate($id);
|
||||||
|
if ($result) {
|
||||||
|
return $this->success('已采纳', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(OpurchaseclassLogic::getError());
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ class SupplierController extends BaseAdminController
|
|||||||
* @notes 获取供应商管理列表
|
* @notes 获取供应商管理列表
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function lists()
|
public function lists()
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ class SupplierController extends BaseAdminController
|
|||||||
* @notes 添加供应商管理
|
* @notes 添加供应商管理
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
@ -51,7 +51,7 @@ class SupplierController extends BaseAdminController
|
|||||||
* @notes 编辑供应商管理
|
* @notes 编辑供应商管理
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ class SupplierController extends BaseAdminController
|
|||||||
* @notes 删除供应商管理
|
* @notes 删除供应商管理
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
@ -82,7 +82,7 @@ class SupplierController extends BaseAdminController
|
|||||||
* @notes 获取供应商管理详情
|
* @notes 获取供应商管理详情
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function detail()
|
public function detail()
|
||||||
{
|
{
|
||||||
@ -91,5 +91,12 @@ class SupplierController extends BaseAdminController
|
|||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setLabel(){
|
||||||
|
$params=$this->request->post();
|
||||||
|
$result = SupplierLogic::setLabel($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('设置成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(SupplierLogic::getError());
|
||||||
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['name', 'class', 'brand', 'unit', 'code', 'warehouse', 'retail_name', 'sort'],
|
'=' => ['name', 'class', 'brand', 'unit', 'code', 'warehouse', 'sort'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class CashierclassLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
$search= [
|
$search= [
|
||||||
'=' => ['merchant', 'store_id', 'customer', 'time', 'number', 'user', 'pay_type', 'type', 'auditinguser'],
|
'=' => ['merchant', 'store_id', 'number', 'user', 'pay_type', 'type', 'auditinguser'],
|
||||||
];
|
];
|
||||||
return $search;
|
return $search;
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ class CashierclassLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return Cashierclass::where($this->searchWhere)
|
return Cashierclass::where($this->searchWhere)
|
||||||
->field(['id', 'merchant', 'store_id', 'customer', 'time', 'number', 'total', 'deduction_price', 'actual', 'money', 'user', 'pay_type', 'type', 'auditinguser', 'auditingtime'])
|
->field(['id', 'merchant', 'store_id', 'number', 'total', 'deduction_price', 'actual', 'money', 'user', 'pay_type', 'type', 'auditinguser', 'auditingtime'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
@ -21,12 +21,12 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
* @notes 设置搜索条件
|
* @notes 设置搜索条件
|
||||||
* @return \string[][]
|
* @return \string[][]
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['name', 'tel', 'supplier_type', 'invoice_type'],
|
'=' => ['category_id', 'type_id', 'mer_name'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,12 +38,12 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return Supplier::where($this->searchWhere)
|
return Supplier::where($this->searchWhere)
|
||||||
->field(['id', 'name', 'py', 'number', 'uid', 'contacts', 'tel', 'bank', 'account', 'tax', 'supplier_type', 'tax_rate', 'invoice_type', 'dept_type'])
|
->field(['id', 'category_id', 'type_id', 'mer_name', 'settle_cycle', 'interest_rate', 'sys_labels', 'mer_address', 'status', 'commission_rate', 'commission_switch', 'mer_money'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
@ -55,7 +55,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
* @notes 获取供应商管理数量
|
* @notes 获取供应商管理数量
|
||||||
* @return int
|
* @return int
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time";
|
$field = "id,nickname,sex,avatar,account,mobile,channel,create_time";
|
||||||
$lists = User::withSearch($this->setSearch(), $this->params)
|
$lists = User::withSearch($this->setSearch(), $this->params)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->field($field)
|
->field($field)
|
||||||
|
@ -39,12 +39,10 @@ class GoodsLogic extends BaseLogic
|
|||||||
'buy' => $params['buy'],
|
'buy' => $params['buy'],
|
||||||
'sell' => $params['sell'],
|
'sell' => $params['sell'],
|
||||||
'retail' => $params['retail'],
|
'retail' => $params['retail'],
|
||||||
'integral' => $params['integral'],
|
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'warehouse' => $params['warehouse'],
|
'warehouse' => $params['warehouse'],
|
||||||
'location' => $params['location'],
|
'location' => $params['location'],
|
||||||
'stocktip' => $params['stocktip'],
|
'stocktip' => $params['stocktip'],
|
||||||
'retail_name' => $params['retail_name'],
|
|
||||||
'imgs' => $params['imgs'],
|
'imgs' => $params['imgs'],
|
||||||
'details' => $params['details'] ? implode(',', $params['details']) : '',
|
'details' => $params['details'] ? implode(',', $params['details']) : '',
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
@ -84,12 +82,10 @@ class GoodsLogic extends BaseLogic
|
|||||||
'buy' => $params['buy'],
|
'buy' => $params['buy'],
|
||||||
'sell' => $params['sell'],
|
'sell' => $params['sell'],
|
||||||
'retail' => $params['retail'],
|
'retail' => $params['retail'],
|
||||||
'integral' => $params['integral'],
|
|
||||||
'code' => $params['code'],
|
'code' => $params['code'],
|
||||||
'warehouse' => $params['warehouse'],
|
'warehouse' => $params['warehouse'],
|
||||||
'location' => $params['location'],
|
'location' => $params['location'],
|
||||||
'stocktip' => $params['stocktip'],
|
'stocktip' => $params['stocktip'],
|
||||||
'retail_name' => $params['retail_name'],
|
|
||||||
'imgs' => $params['imgs'],
|
'imgs' => $params['imgs'],
|
||||||
'details' => $params['details'] ? implode(',', $params['details']) : '',
|
'details' => $params['details'] ? implode(',', $params['details']) : '',
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
|
@ -5,6 +5,10 @@ namespace app\admin\logic\operation;
|
|||||||
|
|
||||||
use app\common\model\operation\Opurchaseclass;
|
use app\common\model\operation\Opurchaseclass;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\goods\Goods;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
use app\common\model\opurchase\Opurchaseinfo;
|
||||||
|
use app\common\model\supplier\Supplier;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
@ -28,9 +32,7 @@ class OpurchaseclassLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Opurchaseclass::create([
|
Opurchaseclass::create([]);
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -53,9 +55,7 @@ class OpurchaseclassLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Opurchaseclass::where('id', $params['id'])->update([
|
Opurchaseclass::where('id', $params['id'])->update([]);
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
@ -89,6 +89,70 @@ class OpurchaseclassLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return Opurchaseclass::findOrEmpty($params['id'])->toArray();
|
$data = Opurchaseclass::findOrEmpty($params['id'])->toArray();
|
||||||
|
if ($data) {
|
||||||
|
$data['info'] = Opurchaseinfo::where('pid', $params['id'])->select()->each(function ($item) {
|
||||||
|
$sys_labels = Goods::where('id', $item['goods'])->value('sys_labels');
|
||||||
|
$supplier_arr=[];
|
||||||
|
if($sys_labels){
|
||||||
|
$arr = explode(',', $sys_labels);
|
||||||
|
foreach ($arr as $k => $v) {
|
||||||
|
if($v>0){
|
||||||
|
$supplier=Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->find();
|
||||||
|
if($supplier){
|
||||||
|
$supplier_arr[]=$supplier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item['supplier'] = array_unique($supplier_arr);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 推送供应商商品
|
||||||
|
* @param $params
|
||||||
|
* @return bool
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public static function createSupplierGoods($params){
|
||||||
|
try{
|
||||||
|
$goods_offer=[];
|
||||||
|
foreach($params['goods_info'] as $k=>$v){
|
||||||
|
$goods_offer[]=[
|
||||||
|
'supplier_id'=>$v['supplier'],
|
||||||
|
'goods_id'=>$v['goods'],
|
||||||
|
'price'=>0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if($goods_offer){
|
||||||
|
$res=OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||||
|
if($res){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (\Exception $e){
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置采纳商品
|
||||||
|
* @param $params
|
||||||
|
* @return bool
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public static function goodsOfferUpdate($params){
|
||||||
|
try{
|
||||||
|
OpurchaseGoodsOffer::where('id',$params)->update(['is_adopt'=>1]);
|
||||||
|
return true;
|
||||||
|
}catch (\Exception $e){
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,11 +54,15 @@ class CartLogic extends BaseLogic
|
|||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/24 10:37
|
* @date 2024/04/24 10:37
|
||||||
*/
|
*/
|
||||||
public static function edit(array $params): bool
|
public static function edit(array $params,$type='inc'): bool
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Cart::where(['uid'=>$params['uid'],'goods_id'=>$params['goods_id']])->inc('cart_num',$params['cart_num'])->update();
|
if($type=='inc'){
|
||||||
|
Cart::where(['uid'=>$params['uid'],'goods_id'=>$params['goods_id']])->inc('cart_num',$params['cart_num'])->update();
|
||||||
|
}else{
|
||||||
|
Cart::where(['uid'=>$params['uid'],'goods_id'=>$params['goods_id']])->dec('cart_num',$params['cart_num'])->update();
|
||||||
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -31,8 +31,7 @@ class CashierclassLogic extends BaseLogic
|
|||||||
Cashierclass::create([
|
Cashierclass::create([
|
||||||
'merchant' => $params['merchant'],
|
'merchant' => $params['merchant'],
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'customer' => $params['customer'],
|
'uid' => $params['uid'],
|
||||||
'time' => $params['time'],
|
|
||||||
'number' => $params['number'],
|
'number' => $params['number'],
|
||||||
'total' => $params['total'],
|
'total' => $params['total'],
|
||||||
'deduction_price' => $params['deduction_price'],
|
'deduction_price' => $params['deduction_price'],
|
||||||
@ -41,8 +40,6 @@ class CashierclassLogic extends BaseLogic
|
|||||||
'pay_type' => $params['pay_type'],
|
'pay_type' => $params['pay_type'],
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
'type' => $params['type'],
|
'type' => $params['type'],
|
||||||
'auditinguser' => $params['auditinguser'],
|
|
||||||
'auditingtime' => strtotime($params['auditingtime']),
|
|
||||||
'more' => $params['more']
|
'more' => $params['more']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -70,8 +67,7 @@ class CashierclassLogic extends BaseLogic
|
|||||||
Cashierclass::where('id', $params['id'])->update([
|
Cashierclass::where('id', $params['id'])->update([
|
||||||
'merchant' => $params['merchant'],
|
'merchant' => $params['merchant'],
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'customer' => $params['customer'],
|
'uid' => $params['uid'],
|
||||||
'time' => $params['time'],
|
|
||||||
'number' => $params['number'],
|
'number' => $params['number'],
|
||||||
'total' => $params['total'],
|
'total' => $params['total'],
|
||||||
'deduction_price' => $params['deduction_price'],
|
'deduction_price' => $params['deduction_price'],
|
||||||
@ -80,8 +76,6 @@ class CashierclassLogic extends BaseLogic
|
|||||||
'pay_type' => $params['pay_type'],
|
'pay_type' => $params['pay_type'],
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
'type' => $params['type'],
|
'type' => $params['type'],
|
||||||
'auditinguser' => $params['auditinguser'],
|
|
||||||
'auditingtime' => strtotime($params['auditingtime']),
|
|
||||||
'more' => $params['more']
|
'more' => $params['more']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -22,32 +22,37 @@ class SupplierLogic extends BaseLogic
|
|||||||
* @param array $params
|
* @param array $params
|
||||||
* @return bool
|
* @return bool
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public static function add(array $params): bool
|
public static function add(array $params): bool
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Supplier::create([
|
Supplier::create([
|
||||||
'name' => $params['name'],
|
'category_id' => $params['category_id'],
|
||||||
'py' => $params['py'],
|
'type_id' => $params['type_id'],
|
||||||
'number' => $params['number'],
|
'mer_name' => $params['mer_name'],
|
||||||
'uid' => $params['uid'],
|
'settle_cycle' => $params['settle_cycle'],
|
||||||
'contacts' => $params['contacts'],
|
'interest_rate' => $params['interest_rate'],
|
||||||
'tel' => $params['tel'],
|
'sys_labels' => $params['sys_labels'],
|
||||||
'add' => $params['add'],
|
'city_id' => $params['city_id'],
|
||||||
'bank' => $params['bank'],
|
'area_id' => $params['area_id'],
|
||||||
'account' => $params['account'],
|
'street_id' => $params['street_id'],
|
||||||
'tax' => $params['tax'],
|
'village_id' => $params['village_id'],
|
||||||
'other' => $params['other'],
|
'mer_address' => $params['mer_address'],
|
||||||
'email' => $params['email'],
|
'mer_avatar' => $params['mer_avatar'],
|
||||||
'data' => $params['data'],
|
'mark' => $params['mark'],
|
||||||
'more' => $params['more'],
|
'status' => $params['status'],
|
||||||
'supplier_type' => $params['supplier_type'],
|
'commission_rate' => $params['commission_rate'],
|
||||||
'tax_rate' => $params['tax_rate'],
|
'commission_switch' => $params['commission_switch'],
|
||||||
'invoice_type' => $params['invoice_type'],
|
'long' => $params['long'],
|
||||||
'dept_type' => $params['dept_type'],
|
'lat' => $params['lat'],
|
||||||
'sort' => $params['sort']
|
'service_phone' => $params['service_phone'],
|
||||||
|
'mer_money' => $params['mer_money'],
|
||||||
|
'financial_bank' => $params['financial_bank'],
|
||||||
|
'financial_wechat' => $params['financial_wechat'],
|
||||||
|
'financial_alipay' => $params['financial_alipay'],
|
||||||
|
'financial_type' => $params['financial_type']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -65,32 +70,37 @@ class SupplierLogic extends BaseLogic
|
|||||||
* @param array $params
|
* @param array $params
|
||||||
* @return bool
|
* @return bool
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public static function edit(array $params): bool
|
public static function edit(array $params): bool
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Supplier::where('id', $params['id'])->update([
|
Supplier::where('id', $params['id'])->update([
|
||||||
'name' => $params['name'],
|
'category_id' => $params['category_id'],
|
||||||
'py' => $params['py'],
|
'type_id' => $params['type_id'],
|
||||||
'number' => $params['number'],
|
'mer_name' => $params['mer_name'],
|
||||||
'uid' => $params['uid'],
|
'settle_cycle' => $params['settle_cycle'],
|
||||||
'contacts' => $params['contacts'],
|
'interest_rate' => $params['interest_rate'],
|
||||||
'tel' => $params['tel'],
|
'sys_labels' => $params['sys_labels'],
|
||||||
'add' => $params['add'],
|
'city_id' => $params['city_id'],
|
||||||
'bank' => $params['bank'],
|
'area_id' => $params['area_id'],
|
||||||
'account' => $params['account'],
|
'street_id' => $params['street_id'],
|
||||||
'tax' => $params['tax'],
|
'village_id' => $params['village_id'],
|
||||||
'other' => $params['other'],
|
'mer_address' => $params['mer_address'],
|
||||||
'email' => $params['email'],
|
'mer_avatar' => $params['mer_avatar'],
|
||||||
'data' => $params['data'],
|
'mark' => $params['mark'],
|
||||||
'more' => $params['more'],
|
'status' => $params['status'],
|
||||||
'supplier_type' => $params['supplier_type'],
|
'commission_rate' => $params['commission_rate'],
|
||||||
'tax_rate' => $params['tax_rate'],
|
'commission_switch' => $params['commission_switch'],
|
||||||
'invoice_type' => $params['invoice_type'],
|
'long' => $params['long'],
|
||||||
'dept_type' => $params['dept_type'],
|
'lat' => $params['lat'],
|
||||||
'sort' => $params['sort']
|
'service_phone' => $params['service_phone'],
|
||||||
|
'mer_money' => $params['mer_money'],
|
||||||
|
'financial_bank' => $params['financial_bank'],
|
||||||
|
'financial_wechat' => $params['financial_wechat'],
|
||||||
|
'financial_alipay' => $params['financial_alipay'],
|
||||||
|
'financial_type' => $params['financial_type']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -108,7 +118,7 @@ class SupplierLogic extends BaseLogic
|
|||||||
* @param array $params
|
* @param array $params
|
||||||
* @return bool
|
* @return bool
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public static function delete(array $params): bool
|
public static function delete(array $params): bool
|
||||||
{
|
{
|
||||||
@ -121,10 +131,35 @@ class SupplierLogic extends BaseLogic
|
|||||||
* @param $params
|
* @param $params
|
||||||
* @return array
|
* @return array
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($params): array
|
||||||
{
|
{
|
||||||
return Supplier::findOrEmpty($params['id'])->toArray();
|
return Supplier::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置标签
|
||||||
|
* @param $params
|
||||||
|
* @return bool
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public static function setLabel($params)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$value = $params['sys_labels'];
|
||||||
|
if (!empty($value)) {
|
||||||
|
if (!is_array($value)){
|
||||||
|
$value= ',' . $value . ',';
|
||||||
|
}else{
|
||||||
|
$value = ',' . implode(',', $value) . ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Supplier::where('id', $params['id'])->update(['sys_labels' => $value]);
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ class CashierclassValidate extends BaseValidate
|
|||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
'id' => 'require',
|
||||||
'merchant' => 'require',
|
'merchant' => 'require',
|
||||||
'customer' => 'require',
|
'uid' => 'require',
|
||||||
'time' => 'require',
|
'time' => 'require',
|
||||||
'number' => 'require',
|
'number' => 'require',
|
||||||
'total' => 'require',
|
'total' => 'require',
|
||||||
@ -38,7 +38,7 @@ class CashierclassValidate extends BaseValidate
|
|||||||
protected $field = [
|
protected $field = [
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'merchant' => '所属商户',
|
'merchant' => '所属商户',
|
||||||
'customer' => '客户ID',
|
'uid' => '客户ID',
|
||||||
'time' => '单据时间',
|
'time' => '单据时间',
|
||||||
'number' => '单据编号',
|
'number' => '单据编号',
|
||||||
'total' => '单据金额',
|
'total' => '单据金额',
|
||||||
@ -56,7 +56,7 @@ class CashierclassValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['merchant','customer','time','number','total','actual','money','pay_type']);
|
return $this->only(['merchant','number','total','actual','money','pay_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class CashierclassValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','merchant','customer','time','number','total','actual','money','pay_type']);
|
return $this->only(['id','merchant','number','total','actual','money','pay_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,15 @@ class SupplierValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
'id' => 'require',
|
||||||
'name' => 'require',
|
'category_id' => 'require',
|
||||||
|
'mer_name' => 'require',
|
||||||
|
'settle_cycle' => 'require',
|
||||||
|
'interest_rate' => 'require',
|
||||||
|
'mer_address' => 'require',
|
||||||
|
'mark' => 'require',
|
||||||
|
'status' => 'require',
|
||||||
|
'service_phone' => 'require',
|
||||||
|
'mer_money' => 'require',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +38,15 @@ class SupplierValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $field = [
|
protected $field = [
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'name' => '名称',
|
'category_id' => '商户分类 id',
|
||||||
|
'mer_name' => '商户名称',
|
||||||
|
'settle_cycle' => '结算周期,单位天',
|
||||||
|
'interest_rate' => '利率',
|
||||||
|
'mer_address' => '商户地址',
|
||||||
|
'mark' => '商户备注',
|
||||||
|
'status' => '商户是否禁用0锁定,1正常',
|
||||||
|
'service_phone' => '店铺电话',
|
||||||
|
'mer_money' => '商户余额',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -38,11 +54,11 @@ class SupplierValidate extends BaseValidate
|
|||||||
* @notes 添加场景
|
* @notes 添加场景
|
||||||
* @return SupplierValidate
|
* @return SupplierValidate
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['name']);
|
return $this->only(['category_id','mer_name','settle_cycle','interest_rate','mer_address','mark','status','service_phone','mer_money']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,11 +66,11 @@ class SupplierValidate extends BaseValidate
|
|||||||
* @notes 编辑场景
|
* @notes 编辑场景
|
||||||
* @return SupplierValidate
|
* @return SupplierValidate
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','name']);
|
return $this->only(['id','category_id','mer_name','settle_cycle','interest_rate','mer_address','mark','status','service_phone','mer_money']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,7 +78,7 @@ class SupplierValidate extends BaseValidate
|
|||||||
* @notes 删除场景
|
* @notes 删除场景
|
||||||
* @return SupplierValidate
|
* @return SupplierValidate
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function sceneDelete()
|
public function sceneDelete()
|
||||||
{
|
{
|
||||||
@ -74,7 +90,7 @@ class SupplierValidate extends BaseValidate
|
|||||||
* @notes 详情场景
|
* @notes 详情场景
|
||||||
* @return SupplierValidate
|
* @return SupplierValidate
|
||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/23 15:56
|
* @date 2024/04/27 14:33
|
||||||
*/
|
*/
|
||||||
public function sceneDetail()
|
public function sceneDetail()
|
||||||
{
|
{
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
use app\api\validate\LoginAccountValidate;
|
|
||||||
use app\api\logic\LoginLogic;
|
use app\api\logic\LoginLogic;
|
||||||
|
use app\api\validate\{LoginAccountValidate, RegisterValidate, WebScanLoginValidate, WechatLoginValidate};
|
||||||
|
|
||||||
class LoginController extends BaseApiController
|
class LoginController extends BaseApiController
|
||||||
{
|
{
|
||||||
public $notNeedLogin = ['account'];
|
public $notNeedLogin = ['account','logout'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 账号登录
|
||||||
|
*/
|
||||||
public function account()
|
public function account()
|
||||||
{
|
{
|
||||||
$params=$this->request->post();
|
$params=$this->request->post();
|
||||||
@ -19,4 +22,47 @@ class LoginController extends BaseApiController
|
|||||||
}
|
}
|
||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 退出登录
|
||||||
|
*/
|
||||||
|
public function logout()
|
||||||
|
{
|
||||||
|
LoginLogic::logout($this->userInfo);
|
||||||
|
return $this->success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 小程序-登录接口
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/9/20 19:48
|
||||||
|
*/
|
||||||
|
public function mnpLogin()
|
||||||
|
{
|
||||||
|
$params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
|
||||||
|
$res = LoginLogic::mnpLogin($params);
|
||||||
|
if (false === $res) {
|
||||||
|
return $this->fail(LoginLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->success('', $res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 小程序绑定微信
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/9/20 19:48
|
||||||
|
*/
|
||||||
|
public function mnpAuthBind()
|
||||||
|
{
|
||||||
|
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
|
||||||
|
$params['user_id'] = $this->userId;
|
||||||
|
$result = LoginLogic::mnpAuthLogin($params);
|
||||||
|
if ($result === false) {
|
||||||
|
return $this->fail(LoginLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->success('绑定成功', [], 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
17
app/api/controller/goods/GoodsController.php
Normal file
17
app/api/controller/goods/GoodsController.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\goods;
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\goods\GoodsLists;
|
||||||
|
|
||||||
|
class GoodsController extends BaseApiController{
|
||||||
|
public $notNeedLogin = ['lists'];
|
||||||
|
/**
|
||||||
|
* 商品列表
|
||||||
|
*/
|
||||||
|
public function lists(){
|
||||||
|
return $this->dataLists(new GoodsLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
29
app/api/controller/goods/GoodsclassController.php
Normal file
29
app/api/controller/goods/GoodsclassController.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\goods;
|
||||||
|
|
||||||
|
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\goods\GoodsclassLists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类控制器
|
||||||
|
* Class GoodsclassController
|
||||||
|
* @package app\admin\controller\goods
|
||||||
|
*/
|
||||||
|
class GoodsclassController extends BaseApiController
|
||||||
|
{
|
||||||
|
public $notNeedLogin = ['lists'];
|
||||||
|
/**
|
||||||
|
* @notes 获取商品分类列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 10:27
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new GoodsclassLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
15
app/api/controller/merchant/MerchantController.php
Normal file
15
app/api/controller/merchant/MerchantController.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\merchant;
|
||||||
|
|
||||||
|
use app\api\lists\merchant\MerchantLists;
|
||||||
|
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
|
||||||
|
|
||||||
|
class MerchantController extends BaseApiController
|
||||||
|
{
|
||||||
|
public function lists(){
|
||||||
|
return $this->dataLists(new MerchantLists());
|
||||||
|
}
|
||||||
|
}
|
32
app/api/controller/operation/OpurchaseclassController.php
Normal file
32
app/api/controller/operation/OpurchaseclassController.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\operation;
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\operation\OpurchaseGoodsOfferList;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
|
||||||
|
class OpurchaseclassController extends BaseApiController{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报价列表
|
||||||
|
*/
|
||||||
|
public function goods_offer_list(){
|
||||||
|
|
||||||
|
return $this->dataLists(new OpurchaseGoodsOfferList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建报价
|
||||||
|
*/
|
||||||
|
public function create_price(){
|
||||||
|
$id=$this->request->post('id');
|
||||||
|
$price=$this->request->post('price');
|
||||||
|
$nums=$this->request->post('nums');
|
||||||
|
$supplier_id=$this->request->userInfo['supplier']['id'];
|
||||||
|
if(!$supplier_id) return $this->fail('请先绑定供应商');
|
||||||
|
$res=OpurchaseGoodsOffer::where('supplier_id',$supplier_id)->where('id',$id)->update(['price'=>$price,'nums'=>$nums]);
|
||||||
|
if($res) return $this->success('报价成功');
|
||||||
|
return $this->fail('报价失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,14 +5,26 @@ namespace app\api\controller\order;
|
|||||||
use app\admin\logic\order\CartLogic;
|
use app\admin\logic\order\CartLogic;
|
||||||
use app\admin\validate\order\CartValidate;
|
use app\admin\validate\order\CartValidate;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\order\CartList;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
|
|
||||||
class CartController extends BaseApiController
|
class CartController extends BaseApiController
|
||||||
{
|
{
|
||||||
|
public function list(){
|
||||||
|
return $this->dataLists(new CartList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加购物车
|
||||||
|
*/
|
||||||
public function create(){
|
public function create(){
|
||||||
$params = (new CartValidate())->get()->goCheck('add');
|
$params = (new CartValidate())->post()->goCheck('add');
|
||||||
$params['uid']=1;
|
$params['uid']=$this->request->userId;
|
||||||
$result=Cart::where(['uid'=>$params['uid'],'goods_id'=>$params['goods_id'],'is_fail'=>0,'is_pay'=>0])->find();
|
$result=Cart::where(['uid'=>$params['uid'],'goods_id'=>$params['goods_id'],'is_fail'=>0,'is_pay'=>0])->find();
|
||||||
|
$count=Cart::where(['uid'=>$params['uid'],'is_fail'=>0,'is_pay'=>0])->count();
|
||||||
|
if($count>100){
|
||||||
|
return $this->fail('购物车商品不能大于100个,请先结算');
|
||||||
|
}
|
||||||
if($result){
|
if($result){
|
||||||
$res=CartLogic::edit($params);
|
$res=CartLogic::edit($params);
|
||||||
}else{
|
}else{
|
||||||
@ -25,4 +37,33 @@ class CartController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 修改购物车
|
||||||
|
*/
|
||||||
|
public function change(){
|
||||||
|
$params = (new CartValidate())->post()->goCheck('change');
|
||||||
|
$params['uid']=$this->request->userId;
|
||||||
|
$res=CartLogic::edit($params,'dec');
|
||||||
|
if($res){
|
||||||
|
return $this->success('修改成功');
|
||||||
|
}else{
|
||||||
|
return $this->fail(CartLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 删除购物车
|
||||||
|
*/
|
||||||
|
public function delete(){
|
||||||
|
$params = (new CartValidate())->post()->goCheck('delete');
|
||||||
|
$params['uid']=$this->request->userId;
|
||||||
|
$res=CartLogic::delete($params);
|
||||||
|
if($res){
|
||||||
|
return $this->success('删除成功');
|
||||||
|
}else{
|
||||||
|
return $this->fail(CartLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -5,14 +5,26 @@ namespace app\api\controller\order;
|
|||||||
use app\admin\logic\order\CartLogic;
|
use app\admin\logic\order\CartLogic;
|
||||||
use app\api\logic\order\OrderLogic;
|
use app\api\logic\order\OrderLogic;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\order\RetailOrderList;
|
||||||
use app\common\logic\order\RetailOrderLogic;
|
use app\common\logic\order\RetailOrderLogic;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
|
use app\common\model\retail\Cashierclass;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
|
|
||||||
class RetailOrderController extends BaseApiController
|
class RetailOrderController extends BaseApiController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单列表
|
||||||
|
*/
|
||||||
|
public function order_list(){
|
||||||
|
|
||||||
|
return $this->dataLists(new RetailOrderList());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 检测零售订单
|
||||||
|
*/
|
||||||
public function checkOrder(){
|
public function checkOrder(){
|
||||||
$cartId = (Array)$this->request->post('cart_id', []);
|
$cartId = (Array)$this->request->post('cart_id', []);
|
||||||
$addressId = (int)$this->request->post('address_id');
|
$addressId = (int)$this->request->post('address_id');
|
||||||
@ -20,6 +32,13 @@ class RetailOrderController extends BaseApiController
|
|||||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||||
$params=$this->request->post();
|
$params=$this->request->post();
|
||||||
$res=OrderLogic::cartIdByOrderInfo($cartId,$addressId,null,$params);
|
$res=OrderLogic::cartIdByOrderInfo($cartId,$addressId,null,$params);
|
||||||
|
if($res==false){
|
||||||
|
$msg=OrderLogic::getError();
|
||||||
|
if($msg=='购物车为空'){
|
||||||
|
return $this->data([]);
|
||||||
|
}
|
||||||
|
return $this->fail(OrderLogic::getError());
|
||||||
|
}
|
||||||
return $this->data($res);
|
return $this->data($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +49,9 @@ class RetailOrderController extends BaseApiController
|
|||||||
|
|
||||||
$user=User::where('id',$this->request->userId)->find();
|
$user=User::where('id',$this->request->userId)->find();
|
||||||
$cartId = (Array)$this->request->post('cart_id', []);
|
$cartId = (Array)$this->request->post('cart_id', []);
|
||||||
|
if(count($cartId)>100){
|
||||||
|
return $this->fail('购物车商品不能超过100个');
|
||||||
|
}
|
||||||
$addressId = (int)$this->request->post('address_id');
|
$addressId = (int)$this->request->post('address_id');
|
||||||
$pay_type = (int)$this->request->post('pay_type');
|
$pay_type = (int)$this->request->post('pay_type');
|
||||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||||
@ -54,4 +76,47 @@ class RetailOrderController extends BaseApiController
|
|||||||
return $this->fail(OrderLogic::getError());
|
return $this->fail(OrderLogic::getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重新支付
|
||||||
|
*/
|
||||||
|
public function Repayment(){
|
||||||
|
$order_id = (int)$this->request->post('order_id');
|
||||||
|
$pay_type = (int)$this->request->post('pay_type');
|
||||||
|
$where=[
|
||||||
|
'order_id'=>$order_id,
|
||||||
|
'uid'=>$this->userId,
|
||||||
|
'paid'=>0,
|
||||||
|
];
|
||||||
|
$order=Cashierclass::where($where)->find();
|
||||||
|
if($pay_type==PayEnum::BALANCE_PAY){
|
||||||
|
$user=User::where('id',$this->request->userId)->find();
|
||||||
|
$res=RetailOrderLogic::payBalance($user,$order);
|
||||||
|
if($res==true){
|
||||||
|
$res=RetailOrderLogic::paySuccess($order, ['money'=>$order['actual']]);
|
||||||
|
if($res){
|
||||||
|
}else{
|
||||||
|
return $this->fail(RetailOrderLogic::getError());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return $this->fail(RetailOrderLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->fail('支付失败');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户常用购买记录
|
||||||
|
*/
|
||||||
|
public function frequently_purchase(){
|
||||||
|
$params=$this->request->get();
|
||||||
|
$res=RetailOrderLogic::frequentlyPurchase($params);
|
||||||
|
if($res==false){
|
||||||
|
return $this->fail(RetailOrderLogic::getError());
|
||||||
|
}else{
|
||||||
|
return $this->data($res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
77
app/api/controller/user/AddressController.php
Normal file
77
app/api/controller/user/AddressController.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\user;
|
||||||
|
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
use app\api\lists\user\UserAddressList;
|
||||||
|
use app\api\logic\user\AddressLogic;
|
||||||
|
use app\api\validate\UserAddressValidate;
|
||||||
|
|
||||||
|
class AddressController extends BaseApiController
|
||||||
|
{
|
||||||
|
public function lists(){
|
||||||
|
return $this->dataLists(new UserAddressList());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 添加地址
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/4/24 10:37
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$params = (new UserAddressValidate())->post()->goCheck('add');
|
||||||
|
$params['uid'] = $this->request->userId;
|
||||||
|
$res=AddressLogic::add($params);
|
||||||
|
if($res){
|
||||||
|
return $this->success('添加成功');
|
||||||
|
}else{
|
||||||
|
return $this->fail(AddressLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 编辑地址
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/4/24 10:37
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new UserAddressValidate())->post()->goCheck('edit');
|
||||||
|
$params['uid'] = $this->request->userId;
|
||||||
|
if(AddressLogic::edit($params)){
|
||||||
|
return $this->success('编辑成功');
|
||||||
|
}else{
|
||||||
|
return $this->fail(AddressLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除地址
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/4/24 10:37
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new UserAddressValidate())->post()->goCheck('delete');
|
||||||
|
if(AddressLogic::delete($params)){
|
||||||
|
return $this->success('删除成功');
|
||||||
|
}else{
|
||||||
|
return $this->fail(AddressLogic::getError());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取地址详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/4/24 10:37
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new UserAddressValidate())->goCheck('detail');
|
||||||
|
return $this->success('获取成功',AddressLogic::detail($params));
|
||||||
|
}
|
||||||
|
}
|
24
app/api/lists/BaseApiDataLists.php
Normal file
24
app/api/lists/BaseApiDataLists.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\api\lists;
|
||||||
|
|
||||||
|
use app\common\lists\BaseDataLists;
|
||||||
|
|
||||||
|
abstract class BaseApiDataLists extends BaseDataLists
|
||||||
|
{
|
||||||
|
protected array $userInfo = [];
|
||||||
|
protected int $userId = 0;
|
||||||
|
|
||||||
|
public string $export;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
if (isset($this->request->userInfo) && $this->request->userInfo) {
|
||||||
|
$this->userInfo = $this->request->userInfo;
|
||||||
|
$this->userId = $this->request->userId;
|
||||||
|
}
|
||||||
|
$this->export = $this->request->get('export', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
114
app/api/lists/goods/GoodsLists.php
Normal file
114
app/api/lists/goods/GoodsLists.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\goods;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\goods\Goods;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\goods\Goodsclass;
|
||||||
|
use app\common\model\goods\GoodsLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品列表列表
|
||||||
|
* Class goods
|
||||||
|
* @package app\api\goods
|
||||||
|
*/
|
||||||
|
class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'%like%' => ['name'],
|
||||||
|
'=' => ['class']
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 设置支持排序字段
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:07
|
||||||
|
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
|
||||||
|
*/
|
||||||
|
public function setSortFields(): array
|
||||||
|
{
|
||||||
|
return ['sell' => 'sell', 'sales' => 'sales',];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置默认排序
|
||||||
|
* @return string[]
|
||||||
|
* @date 2021/12/29 10:06
|
||||||
|
*/
|
||||||
|
public function setDefaultOrder(): array
|
||||||
|
{
|
||||||
|
return ['sales' => 'desc','sell' => 'asc'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$class_all=$this->request->get('class_all');
|
||||||
|
$where=[];
|
||||||
|
if($class_all){
|
||||||
|
$arr=[];
|
||||||
|
$arr2=[];
|
||||||
|
$arr=Goodsclass::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Goodsclass::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['class','in',array_merge($arr,$arr2)];
|
||||||
|
}else{
|
||||||
|
$where[]=['class','=',$class_all];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Goods::where($this->searchWhere)->where($where)
|
||||||
|
->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs',])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->with(['className','brandName','unitName'])
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品列表数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 11:28
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$class_all=$this->request->get('class_all');
|
||||||
|
$where=[];
|
||||||
|
if($class_all){
|
||||||
|
$arr=[];
|
||||||
|
$arr2=[];
|
||||||
|
$arr=Goodsclass::where('pid',$class_all)->column('id');
|
||||||
|
if($arr){
|
||||||
|
$arr2=Goodsclass::where('pid','in',$arr)->column('id');
|
||||||
|
$where[]=['class','in',array_merge($arr,$arr2)];
|
||||||
|
}else{
|
||||||
|
$where[]=['class','=',$class_all];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Goods::where($this->searchWhere)->where($where)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
67
app/api/lists/goods/GoodsclassLists.php
Normal file
67
app/api/lists/goods/GoodsclassLists.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\goods;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\goods\Goodsclass;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品分类列表
|
||||||
|
* Class GoodsclassLists
|
||||||
|
* @package app\admin\listsgoods
|
||||||
|
*/
|
||||||
|
class GoodsclassLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 10:27
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['pid', 'name', 'data', 'pic', 'sort'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品分类列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 10:27
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$lists= Goodsclass::where($this->searchWhere)
|
||||||
|
->field(['id', 'pid', 'name', 'data', 'pic', 'sort'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
return linear_to_tree($lists, 'children');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取商品分类数量
|
||||||
|
* @return int
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/23 10:27
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return Goodsclass::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
62
app/api/lists/merchant/MerchantLists.php
Normal file
62
app/api/lists/merchant/MerchantLists.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\merchant;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\merchat\Merchant;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商户列表
|
||||||
|
* Class MerchantLists
|
||||||
|
* @package app\api\merchant
|
||||||
|
*/
|
||||||
|
class MerchantLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 商户列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
|
||||||
|
return Merchant::where($this->searchWhere)
|
||||||
|
->field('mer_id,mer_name')
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['mer_id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 商户数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return OpurchaseGoodsOffer::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
61
app/api/lists/operation/OpurchaseGoodsOfferList.php
Normal file
61
app/api/lists/operation/OpurchaseGoodsOfferList.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\operation;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商户报价列表
|
||||||
|
* Class OpurchaseclassLists
|
||||||
|
* @package app\api\operation
|
||||||
|
*/
|
||||||
|
class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商户报价列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$supplier_id=$this->request->userInfo['supplier']['id'];
|
||||||
|
if(!$supplier_id) return [];
|
||||||
|
return OpurchaseGoodsOffer::where($this->searchWhere)->where('supplier_id',$supplier_id)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商户报价数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return OpurchaseGoodsOffer::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
81
app/api/lists/order/CartList.php
Normal file
81
app/api/lists/order/CartList.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\order;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\order\Cart;
|
||||||
|
use app\common\model\retail\Cashierclass;
|
||||||
|
use app\common\lists\ListsExtendInterface;
|
||||||
|
use app\common\model\goods\Goods;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购物车列表
|
||||||
|
* Class RetailOrderList
|
||||||
|
* @package app\api\order
|
||||||
|
*/
|
||||||
|
class CartList extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $total_price;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 购物车列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists($where = []): array
|
||||||
|
{
|
||||||
|
$userId = $this->request->userId;
|
||||||
|
if (!$userId) return [];
|
||||||
|
$list = Cart::where($this->searchWhere)->where('uid', $userId)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['cart_id' => 'desc'])
|
||||||
|
->select()->each(function ($item) {
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$total_price = 0;
|
||||||
|
foreach ($list as $key => &$item) {
|
||||||
|
$sell = Goods::where('id', $item['goods_id'])->value('sell');
|
||||||
|
$item['goods_total_price'] = bcmul($item['cart_num'], $sell, 2);
|
||||||
|
$total_price += $item['goods_total_price'];
|
||||||
|
}
|
||||||
|
$this->total_price=$total_price;
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 购物车数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return Cart::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function extend()
|
||||||
|
{
|
||||||
|
return ['total_price'=>$this->total_price];
|
||||||
|
}
|
||||||
|
}
|
63
app/api/lists/order/RetailOrderList.php
Normal file
63
app/api/lists/order/RetailOrderList.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\order;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\retail\Cashierclass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 零售订单列表
|
||||||
|
* Class RetailOrderList
|
||||||
|
* @package app\api\order
|
||||||
|
*/
|
||||||
|
class RetailOrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['number', 'paid',],
|
||||||
|
'between_time' => 'create_time',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 零售订单列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists($where=[]): array
|
||||||
|
{
|
||||||
|
$userId=$this->request->userId;
|
||||||
|
if(!$userId) return [];
|
||||||
|
return Cashierclass::where($this->searchWhere)->where('uid',$userId)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 零售订单数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return Cashierclass::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
62
app/api/lists/user/UserAddressList.php
Normal file
62
app/api/lists/user/UserAddressList.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\user;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\user\UserAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址列表
|
||||||
|
* Class OpurchaseclassLists
|
||||||
|
* @package app\api\operation
|
||||||
|
*/
|
||||||
|
class UserAddressList extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author likeadmin
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取地址列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$user_id=$this->request->userId;
|
||||||
|
if(!$user_id) return [];
|
||||||
|
return UserAddress::where($this->searchWhere)->where('uid',$user_id)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['address_id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取地址数量
|
||||||
|
* @return int
|
||||||
|
* @date 2024/04/27 11:26
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$user_id=$this->request->userId;
|
||||||
|
return UserAddress::where($this->searchWhere)->where('uid',$user_id)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
8
app/api/logic/operation/OpurchaseGoodsOfferLogic.php
Normal file
8
app/api/logic/operation/OpurchaseGoodsOfferLogic.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
namespace app\api\logic\operation;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||||
|
|
||||||
|
class OpurchaseGoodsOfferLogic extends BaseLogic{
|
||||||
|
|
||||||
|
}
|
@ -24,7 +24,7 @@ class OrderLogic extends BaseLogic
|
|||||||
* @param $params
|
* @param $params
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = []): array
|
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
$where = ['is_pay' => 0, 'is_fail' => 0];
|
$where = ['is_pay' => 0, 'is_fail' => 0];
|
||||||
@ -33,19 +33,24 @@ class OrderLogic extends BaseLogic
|
|||||||
self::setError('购物车为空');
|
self::setError('购物车为空');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/** 计算价格 */
|
try {
|
||||||
foreach ($cart_select as $k => $v) {
|
/** 计算价格 */
|
||||||
$sell = Goods::where(['id' => $v['goods']])->value('sell');
|
foreach ($cart_select as $k => $v) {
|
||||||
$cart_select[$k]['total'] = bcmul($v['cart_num'], $sell, 2);
|
$sell = Goods::where(['id' => $v['goods']])->value('sell');
|
||||||
$cart_select[$k]['price'] = $sell;
|
$cart_select[$k]['total'] = bcmul($v['cart_num'], $sell, 2);
|
||||||
|
$cart_select[$k]['price'] = $sell;
|
||||||
|
}
|
||||||
|
$order = [
|
||||||
|
'time' => time(),
|
||||||
|
'number' => static::getNewOrderId('PF'),
|
||||||
|
'total' => array_sum(array_column($cart_select, 'total')),
|
||||||
|
'pay_type' => $params['pay_type'] ?? 0,
|
||||||
|
'cart_id' => implode(',', $cartId)
|
||||||
|
];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
$order = [
|
|
||||||
'time' => time(),
|
|
||||||
'number' => static::getNewOrderId('PF'),
|
|
||||||
'total' => array_sum(array_column($cart_select, 'total')),
|
|
||||||
'pay_type' => $params['pay_type']??0,
|
|
||||||
'cart_id'=>implode(',',$cartId)
|
|
||||||
];
|
|
||||||
return ['order' => $order, 'cart_list' => $cart_select];
|
return ['order' => $order, 'cart_list' => $cart_select];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +64,7 @@ class OrderLogic extends BaseLogic
|
|||||||
$_order = $orderInfo['order'];
|
$_order = $orderInfo['order'];
|
||||||
$_order['deduction_price'] = 0;
|
$_order['deduction_price'] = 0;
|
||||||
$_order['merchant'] = 0;
|
$_order['merchant'] = 0;
|
||||||
$_order['customer'] = request()->userId;
|
$_order['uid'] = request()->userId;
|
||||||
$_order['money'] = 0;
|
$_order['money'] = 0;
|
||||||
$_order['user'] = request()->userId;
|
$_order['user'] = request()->userId;
|
||||||
$_order['account'] = 0;
|
$_order['account'] = 0;
|
||||||
@ -73,6 +78,7 @@ class OrderLogic extends BaseLogic
|
|||||||
foreach ($goods_list as $k => $v) {
|
foreach ($goods_list as $k => $v) {
|
||||||
$goods_list[$k]['pid'] = $order->id;
|
$goods_list[$k]['pid'] = $order->id;
|
||||||
$goods_list[$k]['merchant'] = 0;
|
$goods_list[$k]['merchant'] = 0;
|
||||||
|
$goods_list[$k]['uid'] = request()->userId;
|
||||||
$goods_list[$k]['room'] = 0;
|
$goods_list[$k]['room'] = 0;
|
||||||
$goods_list[$k]['discount'] = 0;
|
$goods_list[$k]['discount'] = 0;
|
||||||
$goods_list[$k]['warehouse'] = 0;
|
$goods_list[$k]['warehouse'] = 0;
|
||||||
@ -88,30 +94,30 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 获取购货订单购物车商品信息
|
* @notes 获取购货订单购物车商品信息
|
||||||
* @param $params
|
* @param $params
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
static public function cartIdByPurchaseOrderInfo($user, $params)
|
static public function cartIdByPurchaseOrderInfo($user, $params)
|
||||||
{
|
{
|
||||||
if(!$user){
|
if (!$user) {
|
||||||
self::setError('没有用户信息,请先登录');
|
self::setError('没有用户信息,请先登录');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mer_id=$user['merchant']['mer_id'];
|
$mer_id = $user['merchant']['mer_id'];
|
||||||
$where1=['paid'=>1];
|
$where1 = ['paid' => 1];
|
||||||
$cartId=Cashierclass::where('merchant',$mer_id)->whereDay('create_time')->where($where1)->column('cart_id');
|
$cartId = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('cart_id');
|
||||||
if(empty($cartId)){
|
if (empty($cartId)) {
|
||||||
self::setError('没有购物车信息');
|
self::setError('没有购物车信息');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$order_id=Cashierclass::where('merchant',$mer_id)->whereDay('create_time')->where($where1)->column('id');
|
$order_id = Cashierclass::where('merchant', $mer_id)->whereDay('create_time')->where($where1)->column('id');
|
||||||
$cart_arr=[];
|
$cart_arr = [];
|
||||||
foreach($cartId as $k=>$v){
|
foreach ($cartId as $k => $v) {
|
||||||
$arr=explode(',',$v);
|
$arr = explode(',', $v);
|
||||||
foreach($arr as $kk=>$vv){
|
foreach ($arr as $kk => $vv) {
|
||||||
$cart_arr[]=$vv;
|
$cart_arr[] = $vv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$where = ['is_pay' => 1, 'is_fail' => 0];
|
$where = ['is_pay' => 1, 'is_fail' => 0];
|
||||||
@ -130,9 +136,9 @@ class OrderLogic extends BaseLogic
|
|||||||
'time' => time(),
|
'time' => time(),
|
||||||
'number' => static::getNewOrderId('CG'),
|
'number' => static::getNewOrderId('CG'),
|
||||||
'total' => array_sum(array_column($cart_select, 'total')),
|
'total' => array_sum(array_column($cart_select, 'total')),
|
||||||
'pay_type' => $params['pay_type']??0,
|
'pay_type' => $params['pay_type'] ?? 0,
|
||||||
'cart_id'=>implode(',',$cart_arr),
|
'cart_id' => implode(',', $cart_arr),
|
||||||
'order_arr'=>implode(',',$order_id)
|
'order_arr' => implode(',', $order_id)
|
||||||
];
|
];
|
||||||
return ['order' => $order, 'cart_list' => $cart_select];
|
return ['order' => $order, 'cart_list' => $cart_select];
|
||||||
}
|
}
|
||||||
@ -143,18 +149,18 @@ class OrderLogic extends BaseLogic
|
|||||||
static public function createOpurchaseOrder($user = null, $params = [])
|
static public function createOpurchaseOrder($user = null, $params = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!$user){
|
if (!$user) {
|
||||||
self::setError('没有用户信息,请先登录');
|
self::setError('没有用户信息,请先登录');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mer_id=$user['merchant']['mer_id'];
|
$mer_id = $user['merchant']['mer_id'];
|
||||||
$merchant=Merchant::where('mer_id',$mer_id)->find();
|
$merchant = Merchant::where('mer_id', $mer_id)->find();
|
||||||
$orderInfo = self::cartIdByPurchaseOrderInfo($user, $params);
|
$orderInfo = self::cartIdByPurchaseOrderInfo($user, $params);
|
||||||
if(!$orderInfo){
|
if (!$orderInfo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$_order = $orderInfo['order'];
|
$_order = $orderInfo['order'];
|
||||||
if($_order['total']<$merchant['mer_money']){
|
if ($_order['total'] < $merchant['mer_money']) {
|
||||||
self::setError('商户余额不足');
|
self::setError('商户余额不足');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -171,9 +177,9 @@ class OrderLogic extends BaseLogic
|
|||||||
$goods_list[$k]['nums'] = $v['cart_num'];
|
$goods_list[$k]['nums'] = $v['cart_num'];
|
||||||
}
|
}
|
||||||
(new Opurchaseinfo())->saveAll($goods_list);
|
(new Opurchaseinfo())->saveAll($goods_list);
|
||||||
$merchant->mer_money=bcsub($merchant->mer_money,$_order['total'],2);
|
$merchant->mer_money = bcsub($merchant->mer_money, $_order['total'], 2);
|
||||||
$order_arr=explode(',',$_order['order_arr']);
|
$order_arr = explode(',', $_order['order_arr']);
|
||||||
Cashierclass::where('id','in',$order_arr)->update(['is_opurchase'=>1]);
|
Cashierclass::where('id', 'in', $order_arr)->update(['is_opurchase' => 1]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return $order;
|
return $order;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
96
app/api/logic/user/AddressLogic.php
Normal file
96
app/api/logic/user/AddressLogic.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\logic\user;
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\user\UserAddress;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址逻辑
|
||||||
|
* Class OrderLogic
|
||||||
|
* @package app\api\logic\order
|
||||||
|
*/
|
||||||
|
class AddressLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加地址表
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/24 10:37
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
UserAddress::create([
|
||||||
|
'uid' => $params['uid'],
|
||||||
|
'real_name' => $params['real_name'],
|
||||||
|
'phone' => $params['phone'],
|
||||||
|
'detail' => $params['detail'],
|
||||||
|
]);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑地址表
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/24 10:37
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$data = [
|
||||||
|
'real_name' => $params['real_name'],
|
||||||
|
'phone' => $params['phone'],
|
||||||
|
'detail' => $params['detail'],
|
||||||
|
];
|
||||||
|
UserAddress::where('uid', $params['uid'])->where('address_id', $params['address_id'])->update($data);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除地址表
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/24 10:37
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return UserAddress::destroy($params['address_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取购物车表详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/24 10:37
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return UserAddress::field('address_id,real_name,phone,detail')->findOrEmpty($params['address_id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
91
app/api/validate/UserAddressValidate.php
Normal file
91
app/api/validate/UserAddressValidate.php
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\validate;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UserAddress验证器
|
||||||
|
* Class UserAddressValidate
|
||||||
|
* @package app\admin\validate
|
||||||
|
*/
|
||||||
|
class UserAddressValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'real_name' => 'require',
|
||||||
|
'phone' => 'require',
|
||||||
|
'detail' => 'require',
|
||||||
|
'address_id' => 'require',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
|
||||||
|
'real_name' => '收货人姓名',
|
||||||
|
'phone' => '收货人电话',
|
||||||
|
'detail' => '收货人详细地址',
|
||||||
|
'address_id' => '地址id',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return UserAddressValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/28 17:28
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['real_name','phone','detail']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return UserAddressValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/28 17:28
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['real_name','phone','detail','address_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return UserAddressValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/28 17:28
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['address_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return UserAddressValidate
|
||||||
|
* @author likeadmin
|
||||||
|
* @date 2024/04/28 17:28
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['address_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
app/api/validate/WechatLoginValidate.php
Normal file
96
app/api/validate/WechatLoginValidate.php
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\api\validate;
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信登录验证
|
||||||
|
* Class WechatLoginValidate
|
||||||
|
* @package app\api\validate
|
||||||
|
*/
|
||||||
|
class WechatLoginValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
protected $rule = [
|
||||||
|
'code' => 'require',
|
||||||
|
'nickname' => 'require',
|
||||||
|
'headimgurl' => 'require',
|
||||||
|
'openid' => 'require',
|
||||||
|
'access_token' => 'require',
|
||||||
|
'terminal' => 'require',
|
||||||
|
'avatar' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $message = [
|
||||||
|
'code.require' => 'code缺少',
|
||||||
|
'nickname.require' => '昵称缺少',
|
||||||
|
'headimgurl.require' => '头像缺少',
|
||||||
|
'openid.require' => 'opendid缺少',
|
||||||
|
'access_token.require' => 'access_token缺少',
|
||||||
|
'terminal.require' => '终端参数缺少',
|
||||||
|
'avatar.require' => '头像缺少',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 公众号登录场景
|
||||||
|
* @return WechatLoginValidate
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/9/16 10:57
|
||||||
|
*/
|
||||||
|
public function sceneOa()
|
||||||
|
{
|
||||||
|
return $this->only(['code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 小程序-授权登录场景
|
||||||
|
* @return WechatLoginValidate
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/9/16 11:15
|
||||||
|
*/
|
||||||
|
public function sceneMnpLogin()
|
||||||
|
{
|
||||||
|
return $this->only(['code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes
|
||||||
|
* @return WechatLoginValidate
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2022/9/16 11:15
|
||||||
|
*/
|
||||||
|
public function sceneWechatAuth()
|
||||||
|
{
|
||||||
|
return $this->only(['code']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 更新用户信息场景
|
||||||
|
* @return WechatLoginValidate
|
||||||
|
* @author 段誉
|
||||||
|
* @date 2023/2/22 11:14
|
||||||
|
*/
|
||||||
|
public function sceneUpdateUser()
|
||||||
|
{
|
||||||
|
return $this->only(['nickname', 'avatar']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
3
app/common/cache/UserTokenCache.php
vendored
3
app/common/cache/UserTokenCache.php
vendored
@ -16,6 +16,7 @@
|
|||||||
namespace app\common\cache;
|
namespace app\common\cache;
|
||||||
|
|
||||||
use app\common\model\merchat\Merchant;
|
use app\common\model\merchat\Merchant;
|
||||||
|
use app\common\model\supplier\Supplier;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserSession;
|
use app\common\model\user\UserSession;
|
||||||
use support\Cache;
|
use support\Cache;
|
||||||
@ -74,10 +75,12 @@ class UserTokenCache extends BaseCache
|
|||||||
$user = User::where('id', '=', $userSession->user_id)
|
$user = User::where('id', '=', $userSession->user_id)
|
||||||
->find();
|
->find();
|
||||||
$merchant=Merchant::where('uid',$userSession->user_id)->find();
|
$merchant=Merchant::where('uid',$userSession->user_id)->find();
|
||||||
|
$supplier=Supplier::where('uid',$userSession->user_id)->find();
|
||||||
$userInfo = [
|
$userInfo = [
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'nickname' => $user->nickname,
|
'nickname' => $user->nickname,
|
||||||
'merchant' => $merchant,
|
'merchant' => $merchant,
|
||||||
|
'supplier' => $supplier,
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'sn' => $user->sn,
|
'sn' => $user->sn,
|
||||||
'mobile' => $user->mobile,
|
'mobile' => $user->mobile,
|
||||||
|
@ -5,8 +5,10 @@ namespace app\common\logic\order;
|
|||||||
|
|
||||||
use app\common\enum\OrderEnum;
|
use app\common\enum\OrderEnum;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\goods\Goods;
|
||||||
use app\common\model\order\Cart;
|
use app\common\model\order\Cart;
|
||||||
use app\common\model\order\FinancialRecord;
|
use app\common\model\order\FinancialRecord;
|
||||||
|
use app\common\model\retail\Cashierinfo;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use Exception;
|
use Exception;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
@ -29,7 +31,7 @@ class RetailOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
static public function payBalance(User $user, $order)
|
static public function payBalance(User $user, $order)
|
||||||
{
|
{
|
||||||
if ($user['user_money'] < $order['actual']){
|
if ($user['user_money'] < $order['actual']) {
|
||||||
self::setError('余额不足,请更换支付方式');
|
self::setError('余额不足,请更换支付方式');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -42,7 +44,7 @@ class RetailOrderLogic extends BaseLogic
|
|||||||
'financial_record_sn' => time(),
|
'financial_record_sn' => time(),
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'number_sn' => $order['number'],
|
||||||
'user_id' => $order['customer'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => OrderEnum::USER_ORDER_PAY,
|
'financial_type' => OrderEnum::USER_ORDER_PAY,
|
||||||
'financial_pm' => OrderEnum::EXPENDITURE,
|
'financial_pm' => OrderEnum::EXPENDITURE,
|
||||||
'number' => $order['actual'],
|
'number' => $order['actual'],
|
||||||
@ -55,7 +57,7 @@ class RetailOrderLogic extends BaseLogic
|
|||||||
'financial_record_sn' => time(),
|
'financial_record_sn' => time(),
|
||||||
'order_id' => $order['id'],
|
'order_id' => $order['id'],
|
||||||
'number_sn' => $order['number'],
|
'number_sn' => $order['number'],
|
||||||
'user_id' => $order['customer'],
|
'user_id' => $order['uid'],
|
||||||
'financial_type' => OrderEnum::MERCHANT_ORDER_OBTAINS,
|
'financial_type' => OrderEnum::MERCHANT_ORDER_OBTAINS,
|
||||||
'financial_pm' => OrderEnum::INCOME,
|
'financial_pm' => OrderEnum::INCOME,
|
||||||
'number' => $order['actual'],
|
'number' => $order['actual'],
|
||||||
@ -87,12 +89,12 @@ class RetailOrderLogic extends BaseLogic
|
|||||||
$order->money = $CallbackData['money'];
|
$order->money = $CallbackData['money'];
|
||||||
$order->paid = 1;
|
$order->paid = 1;
|
||||||
$order->save();
|
$order->save();
|
||||||
if($order['cart_id']){
|
if ($order['cart_id']) {
|
||||||
if(!is_array($order['cart_id'])){
|
if (!is_array($order['cart_id'])) {
|
||||||
$cart_arr=explode(',',$order['cart_id']);
|
$cart_arr = explode(',', $order['cart_id']);
|
||||||
Cart::whereIn('cart_id',$cart_arr)->update(['is_pay'=>1]);
|
Cart::whereIn('cart_id', $cart_arr)->update(['is_pay' => 1]);
|
||||||
}else{
|
} else {
|
||||||
Cart::whereIn('cart_id',$order['cart_id'])->update(['is_pay'=>1]);
|
Cart::whereIn('cart_id', $order['cart_id'])->update(['is_pay' => 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::info('支付成功');
|
Log::info('支付成功');
|
||||||
@ -102,10 +104,25 @@ class RetailOrderLogic extends BaseLogic
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// 回滚事务
|
// 回滚事务
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
Log::error('支付失败'.$e->getMessage().'。like:'.$e->getLine());
|
Log::error('支付失败' . $e->getMessage() . '。like:' . $e->getLine());
|
||||||
self::setError('支付失败'.$e->getMessage());
|
self::setError('支付失败' . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户常用购买记录
|
||||||
|
*/
|
||||||
|
public static function frequentlyPurchase($params)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$goods_id = Cashierinfo::where('uid', Request()->uid)->page($params['page'])->limit(50)->column('goods_id');
|
||||||
|
$goods_arr = array_unique($goods_id);
|
||||||
|
$select = Goods::where('id', 'in', $goods_arr)->field('id,name,sell,imgs')->select();
|
||||||
|
return $select;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class Goods extends BaseModel
|
|||||||
}
|
}
|
||||||
public function unitName()
|
public function unitName()
|
||||||
{
|
{
|
||||||
return $this->hasOne(Unit::class,'id','unit')->bind(['unit_name'=>'name']);
|
return $this->hasOne(Unit::class,'id','unit')->bind(['unit_name'=>'name','is_bulk']);
|
||||||
}
|
}
|
||||||
public function warehouseName()
|
public function warehouseName()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ use think\model\concern\SoftDelete;
|
|||||||
class Merchant extends BaseModel
|
class Merchant extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
protected $ok = 'mer_id';
|
||||||
protected $name = 'merchant';
|
protected $name = 'merchant';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
22
app/common/model/opurchase/OpurchaseGoodsOffer.php
Normal file
22
app/common/model/opurchase/OpurchaseGoodsOffer.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\opurchase;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商户报价
|
||||||
|
* Class OpurchaseGoodsOffer
|
||||||
|
* @package app\common\model\OpurchaseGoodsOffer
|
||||||
|
*/
|
||||||
|
class OpurchaseGoodsOffer extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
protected $name = 'OpurchaseGoodsOffer';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,7 +4,6 @@ namespace app\common\model\opurchase;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use think\model\concern\SoftDelete;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,9 +13,7 @@ use think\model\concern\SoftDelete;
|
|||||||
*/
|
*/
|
||||||
class Opurchaseinfo extends BaseModel
|
class Opurchaseinfo extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
|
||||||
protected $name = 'Opurchaseinfo';
|
protected $name = 'Opurchaseinfo';
|
||||||
protected $deleteTime = 'delete_time';
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
22
app/common/model/user/UserAddress.php
Normal file
22
app/common/model/user/UserAddress.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\user;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户地址表
|
||||||
|
* Class UserAddress
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class UserAddress extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $pk = 'address_id';
|
||||||
|
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
}
|
@ -50,7 +50,7 @@ class FileService
|
|||||||
$storage = ConfigService::get('storage', $default);
|
$storage = ConfigService::get('storage', $default);
|
||||||
Cache::set('STORAGE_ENGINE', $storage);
|
Cache::set('STORAGE_ENGINE', $storage);
|
||||||
}
|
}
|
||||||
$domain = $storage ? $storage['domain'] : '';
|
$domain = $storage ? $storage['url'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::format($domain, $uri);
|
return self::format($domain, $uri);
|
||||||
|
@ -41,7 +41,7 @@ class UploadService
|
|||||||
|
|
||||||
// 上传文件
|
// 上传文件
|
||||||
$uriPath = '/'.$saveDir . '/' . date('Ymd');
|
$uriPath = '/'.$saveDir . '/' . date('Ymd');
|
||||||
$saveDir = public_path().$uriPath;
|
$saveDir = 'public'.$uriPath;//public_path().$uriPath;
|
||||||
if (!$StorageDriver->upload($saveDir)) {
|
if (!$StorageDriver->upload($saveDir)) {
|
||||||
throw new Exception($StorageDriver->getError());
|
throw new Exception($StorageDriver->getError());
|
||||||
}
|
}
|
||||||
@ -52,13 +52,12 @@ class UploadService
|
|||||||
$nameEnd = substr($fileInfo['name'], strlen($fileInfo['name'])-5, strlen($fileInfo['name']));
|
$nameEnd = substr($fileInfo['name'], strlen($fileInfo['name'])-5, strlen($fileInfo['name']));
|
||||||
$fileInfo['name'] = $name . $nameEnd;
|
$fileInfo['name'] = $name . $nameEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4、写入数据库中
|
// 4、写入数据库中
|
||||||
$file = File::create([
|
$file = File::create([
|
||||||
'cid' => $cid,
|
'cid' => $cid,
|
||||||
'type' => FileEnum::IMAGE_TYPE,
|
'type' => FileEnum::IMAGE_TYPE,
|
||||||
'name' => $fileInfo['name'],
|
'name' => $fileInfo['name'],
|
||||||
'uri' => 'http://'.request()->host().$uriPath.'/' . str_replace("\\","/", $fileName),
|
'uri' => $saveDir . '/' . str_replace("\\","/", $fileName),
|
||||||
'source' => $source,
|
'source' => $source,
|
||||||
'source_id' => $sourceId,
|
'source_id' => $sourceId,
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
|
@ -40,7 +40,7 @@ class Aliyun extends Server
|
|||||||
);
|
);
|
||||||
$ossClient->uploadFile(
|
$ossClient->uploadFile(
|
||||||
$this->config['bucket'],
|
$this->config['bucket'],
|
||||||
$this->fileName,
|
$save_dir.'/'.$this->fileName,
|
||||||
$this->getRealPath()
|
$this->getRealPath()
|
||||||
);
|
);
|
||||||
} catch (OssException $e) {
|
} catch (OssException $e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user