This commit is contained in:
2025-04-26 11:07:05 +08:00
commit abf553c41b
4942 changed files with 930993 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaCard extends \app\common\model\JunkaCard
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaCardLog extends \app\common\model\JunkaCardLog
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaCode extends \app\common\model\JunkaCode
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaList extends \app\common\model\JunkaList
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaPurchcardLog extends \app\common\model\JunkaPurchcardLog
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 购卡记录
*/
class JunkaReject extends \app\common\model\JunkaReject
{
}

View File

@@ -0,0 +1,56 @@
<?php
namespace app\api\model;
use think\Db;
use think\Exception;
use think\Log;
/**
* 购卡记录
*/
class JunkaStore extends \app\common\model\JunkaStore
{
public static function moneychange($store, $money, $type, $notes, $order_no)
{
Db::startTrans();
$store = JunkaStore::lock(true)->where(['id' => $store->id])->find();
$before_money = $store->money;
try {
// +
if($type == 1) {
$after_money = $store->money + $money;
}else {
// -
$after_money = $store->money - $money;
}
$store->money = $after_money;
$store->save();
if($store) {
JunkaStoreMoneyLog::create([
'store_id' => $store->id,
'before_money' => $before_money,
'after_money' => $after_money,
'money' => $money,
'type' => $type,
'admin_id' => $store->admin_id,
'notes' => $notes,
'data_id' => $order_no,
]);
Db::commit();
}else {
Db::rollback();
Log::write('更新余额时商户未找到-'.$store);
}
}catch (Exception $e) {
Db::rollback();
Log::write($e->getMessage());
}
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace app\api\model;
/**
* 余额变动
*/
class JunkaStoreMoneyLog extends \app\common\model\JunkaStoreMoneyLog
{
}

View File

@@ -0,0 +1,81 @@
<?php
namespace app\api\model;
use think\Db;
use think\Exception;
use think\Log;
use think\Model;
/**
* 订单模型
*/
class Order extends \app\common\model\Order
{
/**
* 查询库存
* @param $type string 卡编码
* @param $number int 数量
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function queryInventory($type, $number)
{
$arr['number'] = 0;
$arr['card_data'] = [];
try {
Db::startTrans();
$junka = new JunkaCard;
$junka_card =
$junka->where(['product_code' => $type])
->where('status', 'in', [1])
->limit(0, $number)
->order('id asc')->select();
$arr['number'] = $junka->where(['product_code' => $type])
->where('status', 'in', [1])
->limit(0, $number)
->order('id asc')->count();
if($junka_card) {
foreach ($junka_card as $kk => $card) {
// // 锁卡的去解锁
// if($card->status == 3) {
// $lock = $this->cardunlock($card);
// // 解锁成功
// if($lock['ret_code'] == 0) {
// $arr['card_data'][] = [
// 'card_number' => $card->card_number,
// 'card_password' => $card->card_password,
// ];
// $card->status = 5; // 状态改成提取中
// }else {
// // 解锁失败 数量 -1
// $arr['number'] -= 1;
// // 失败状态备注
// $card->status_notes = '解锁失败-'. $lock['ret_code'] . '-'. $lock['ret_msg'];
// }
// }else {
$arr['card_data'][] = [
'card_number' => $card->card_number,
'card_password' => $card->card_password,
];;
$card->status = 2; // 状态改成发货
// }
$card->save();
}
}
Db::commit();
return $arr;
}catch (Exception $e) {
Log::write('查询库存错误---' . $e);
Db::rollback();
}
}
}