123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Model\BoxDetail;
- use App\Model\Depart;
- use App\Model\InOutRecord;
- use App\Model\Inventory;
- use App\Model\Product;
- use App\Model\ProductInventory;
- use App\Model\ProductPriceDetail;
- use App\Model\PurchaseOrderInfoForOutBound;
- use App\Service\Box\BoxHookService;
- use App\Service\EmployeeService;
- use App\Service\MeasureService;
- use App\Service\OaService;
- use App\Service\OperationLogService;
- use App\Service\OrderNoService;
- use App\Service\SalesOrderService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Hash;
- class TestController extends BaseController
- {
- public function tt(){
- }
- public function boxInsert(){
- }
- public function aa(){
- // $array = (new SalesOrderService())->salesOrderPdf(['id' => 26604],['id'=>1,'head'=>['id' =>2]]);
- // return view('pdf.salesOrder',['order' => $array]);
- $send_data[] = [
- 'employee_id' => 1,
- 'type' => 2,
- 'state' => 0,
- 'menu_id' => 34,
- 'order_number' => "T9RMO.202408071529012839",
- 'tmp_data' => [
- "T9RMO.202408071529012839",
- "施工单",
- '已完结',
- "ee",
- date('Y-m-d H:i:s'),
- ],
- ];
- (new OaService())->sendWxOaCheckMessage($send_data);dd(11)
- (new OaService())->sendWxMsg(1,2,0,34,["T9RMO.202408071529012839","施工单","待确认","陈庆鹏","2024-08-07 15:29:44"]);dd(1);
- // (new OaService())->sendWxMsg(1,3,2,48,["T9RMO.202408071529012839","拒绝","2024-08-07 15:29:44","(未填写原因)"],"/pages/ReturnExchangeOrder/detail/detail?order_number=55");
- //测试消息发送
- // $tmp_data = [
- // "T9XS.20240824095952611883",
- // '陈庆鹏(订单合同)',
- // '刁法森',
- // date('Y-m-d H:i:s'),
- // ];
- // (new OaService())->sendWxMsg(1,1,0,37,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XS.20240824095952611883");
- $tmp_data = [
- "XNCG202411241422297482",
- "拒绝",
- "2024-11-24 14:22:29",
- "测试"
- ];
- (new OaService())->sendWxMsg(1,3,2,44,$tmp_data,"/pageA/pages/SalesOrder/detail/detail?order_number=T9XX.2024080912410029251");dd(1);
- //测试消息发送
- $tmp_data = [
- "22222",
- '222',
- '审核通过',
- '22222',
- date('Y-m-d H:i:s'),
- ];
- // (new OaService())->sendWxMsg(1,2,1,37,$tmp_data,"/pages/SalesOrder/index/index");
- //测试消息发送
- $tmp_data = [
- "333333",
- '审核通过',
- date('Y-m-d H:i:s'),
- '22222',
- ];
- // (new OaService())->sendWxMsg(1,3,2,37,$tmp_data,"/pages/SalesOrder/index/index");
- die;
- $params = json_decode('{"api_key":"d3848b47-4179-4b02-8d32-b78cd7672c6c","return_url":"https://payment.rummyliver.in/notify/s2pay/payment","mode":"LIVE","order_id":"1710493215363410880003","amount":"501.00","currency":"INR","description":"for payment","name":"iahfi","email":"jvqbgvv2908699@outlook.com","phone":"9329086994","city":"Mumbai","zip_code":"400002","country":"IND"}',true);
- $hash_columns = ['merchant_reference_number','Amount','account_name','account_number','ifsc_code','bank_name','bank_branch','transfer_type','address_line_1', 'address_line_2', 'amount', 'api_key', 'city', 'country', 'currency', 'description', 'email', 'mode', 'name', 'order_id', 'phone', 'return_url', 'state', 'udf1', 'udf2', 'udf3', 'udf4', 'udf5', 'zip_code',];
- sort($hash_columns);
- $hash_data = '3b1db341fa70abc03af5c3676811a82bec99673f';
- foreach ($hash_columns as $column) {
- if (isset($params[$column])) {
- if (strlen($params[$column]) > 0) {
- $hash_data .= '|' . trim($params[$column]);
- }
- }
- }
- $hash = strtoupper(hash("sha512", $hash_data));
- var_dump($hash);die;
- return $hash;
- $text = '这是测试';
- $key = '72f8c912d462b1md034ff46cbedaskc80bf';
- $sign = Hash::make($text.$key);
- var_dump(Hash::check('这是测试'.'72f8c912d462b1md034ff46cbedaskc80bf',$sign));
- var_dump($sign);die;
- }
- public function clear(){
- $in_record = InOutRecord::select('top_depart_id')
- ->groupBy('top_depart_id')
- ->get()->toArray();
- $in_record = array_column($in_record,'top_depart_id');
- $depart = Depart::whereIn('id',$in_record)
- ->pluck('basic_type_id', 'id')
- ->toArray();
- $product_inventory = ProductInventory::whereIn('top_depart_id',$in_record)
- ->select('id','product_id','storehouse_id','number','lock_number','top_depart_id')
- ->get()->toArray();
- $product_inventory_map = [];
- foreach ($product_inventory as $value){
- $key = $value['top_depart_id'] . $value['product_id'];
- $product_inventory_map[$key] = 111;
- }
- $record_list = InOutRecord::where('del_time',0)
- ->whereIn('top_depart_id',$in_record)
- ->get()->toArray();
- $list = [];$error1 = [];
- foreach ($record_list as $value){
- $key = $value['top_depart_id'] . $value['product_id'];
- if(! isset($product_inventory_map[$key])){
- $error1[] = $value;
- }else{
- if(isset($list[$key])){
- $number = bcadd($value['number'],$list[$key],2);
- $list[$key] = $number;
- }else{
- $list[$key] = $value['number'];
- }
- }
- }
- if(! empty($error1)){
- foreach ($error1 as $value){
- InOutRecord::where('id', $value['id'])->update(['del_time' => 1233]);
- }dd(1);
- }
- $error = [];
- foreach ($product_inventory as $value){
- $key = $value['top_depart_id'] . $value['product_id'];
- if(isset($list[$key])){
- $tmp = $list[$key];
- if($tmp != $value['number']){
- $numbers = bcsub($value['number'],$tmp,2);
- $error[] = [
- 'product_id' => $value['product_id'],
- 'top_depart_id' => $value['top_depart_id'],
- 'depart_id' => $value['top_depart_id'],
- 'storehouse_id' => $value['storehouse_id'],
- 'number' => $numbers,
- ];
- }
- }else{
- $error[] = [
- 'product_id' => $value['product_id'],
- 'top_depart_id' => $value['top_depart_id'],
- 'depart_id' => $value['top_depart_id'],
- 'storehouse_id' => $value['storehouse_id'],
- 'number' => $value['number'],
- ];
- }
- }
- if(empty($error)) dd('no data');
- dd($error);
- $price_detail_map = [];
- $price_detail = ProductPriceDetail::whereIn('product_id',array_unique(array_column($error,'product_id')))
- ->select('product_id','price','basic_type_id')
- ->get()->toArray();
- foreach ($price_detail as $value){
- $price_detail_map[$value['product_id'] . $value['basic_type_id']] = $value['price'];
- }
- $price_2 = Product::whereIn('id',array_unique(array_column($error,'product_id')))
- ->pluck('retail_price','id')
- ->toArray();
- foreach ($error as $e => $value){
- $basic_type_id = $depart[$value['top_depart_id']] ?? 0;
- $key = $value['product_id'] . $basic_type_id;
- $price = $price_detail_map[$key] ?? 0;
- if(! $price) $price = $price_2[$value['product_id']] ?? 0;
- if(! $price) dd(1);
- if(! $value['number'] > 0) dd(2222);
- $error[$e]['price'] = $price;
- $error[$e]['crt_time'] = 1740758399;
- $error[$e]['order_type'] = PurchaseOrderInfoForOutBound::prefix2;
- $error[$e]['order_number'] = (new OrderNoService())->createOrderNumber(PurchaseOrderInfoForOutBound::prefix2);
- }
- InOutRecord::insert($error);
- dd(count($error),$error);
- }
- }
|