麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > 建站經驗 > 正文

ecshop教程:自動分成函數程序代碼

2024-04-25 20:43:49
字體:
來源:轉載
供稿:網友

ecshop自動分成程序代碼,大概邏輯:

后臺操作一個訂單發貨的時候進行自動分成,后臺取消發貨,退貨,改為未發貨的時候去掉自動分成部分。

核心代碼:lib_common.php

//分成積分計算

function fenchenjifen($usertype=3,$point){

$affiliate = unserialize($GLOBALS['_CFG']['affiliate']);

if($usertype==3){ //采購

if ($affiliate['config']['level_register_up'])

{

$affiliate['config']['level_register_up'] /= 100;

}

$point_cg = round($affiliate['config']['level_register_up'] * intval($point), 0);

return $point_cg;

}

if($usertype==1){//經銷商

if ($affiliate['config']['level_money_all'])

{

$affiliate['config']['level_money_all'] /= 100;

}

$point_cg = round($affiliate['config']['level_money_all'] * intval($point), 0);

return $point_cg;

}

if($usertype==2){//財務

if ($affiliate['config']['level_register_all'])

{

$affiliate['config']['level_register_all'] /= 100;

}

$point_cg = round($affiliate['config']['level_register_all'] * intval($point), 0);

return $point_cg;

}

}

/**

*

* @param undefined $order 訂單信息

* @param undefined $buyuser 購買者信息

* @param undefined $integral 計算積分

* $type = 1 增加 $type=-1 撤銷

* 分成log狀態99

*/

function fun_fencheng_change($order,$buyuser,$integral=array(),$type=1){//店鋪分成計算

if(intval($order['parent_shopid'])==0) return false;

if(!is_array($buyuser)) return false;

$order_id=$order['order_id'];

$separate_by=99;

switch($buyuser['usertype']){

case '0'://購買者類型

$row = $GLOBALS['db']->getRow("SELECT * from " . $GLOBALS['ecs']->table('users') . " u ".

" WHERE u.shopid =".$order['parent_shopid']." and u.usertype=1"

);//獲取pid

$up_uid = $row['user_id'];

if(!empty($up_uid) && $up_uid > 0)

{

$money=$point=0;

$point= fenchenjifen(1,$integral['custom_points']);

// $info = sprintf($GLOBALS['_LANG']['separate_info'], $order['order_sn'], $money, $point);

$info="訂單".$order['order_sn']."分成獲得積分:".$point;

log_account_change($up_uid, $money, 0, ($type)*$point, ($type)*$point, $info);

//var_dump($info);

if($type==1){

write_affiliate_log1($order_id, $up_uid, $row['user_name'], $money, $point, $separate_by);

}else{

rollback_affiliate_log($order_id);

}

$orderupdate['is_separate']=$type==1?$separate_by:0;

$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'),

$orderupdate, 'UPDATE', "order_id = '$order_id'");

}

break;

case '3':

$row = $GLOBALS['db']->getAll("SELECT u.shopid,u.user_id,u.usertype, u.user_name FROM " . $GLOBALS['ecs']->table('users') . " u ".

" WHERE u.shopid= ".$order['parent_shopid']." and u.usertype in (1,2)");

foreach($row as $val){ // 經銷商和財務獲得分成

if($val['usertype']==1){

$pointf = fenchenjifen(1,$integral['custom_points']);

}

if($val['usertype']==2){

$pointf = fenchenjifen(2,$integral['custom_points']);

}

$up_uid = $val['user_id'];

//$info = sprintf($GLOBALS['_LANG']['separate_info'], $order['order_sn'], $money, $pointf);

$info="訂單".$order['order_sn']."分成獲得積分:".$pointf;

log_account_change($up_uid, $money, 0, ($type)*$pointf, ($type)*$pointf, $info);

if($type==1){

write_affiliate_log1($order_id, $up_uid, $val['user_name'], $money, $pointf, $separate_by);

}else{

rollback_affiliate_log($order_id);

}

$orderupdate['is_separate']=$type==1?$separate_by:0;

$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table('order_info'),

$orderupdate, 'UPDATE', "order_id = '$order_id'");

}

break;

}

return true;

}

/**

*

* @param undefined $oid

* @param undefined $uid

* @param undefined $username

* @param undefined $money

* @param undefined $point

* @param undefined $separate_by

* 寫入訂單分成 log

*/

function write_affiliate_log1($oid, $uid, $username, $money, $point, $separate_by)

{

$time = gmtime();

$sql = "INSERT INTO " . $GLOBALS['ecs']->table('affiliate_log') . "( order_id, user_id, user_name, time, money, point, separate_type)".

" VALUES ( '$oid', '$uid', '$username', '$time', '$money', '$point', $separate_by)";

if ($oid)

{

$GLOBALS['db']->query($sql);

}

}

//撤銷訂單分成

function rollback_affiliate_log($order_id,$falg=-2){

$sql = "UPDATE " . $GLOBALS['ecs']->table('affiliate_log') .

" SET separate_type = '$falg'" .

" WHERE order_id = '$order_id'";

$GLOBALS['db']->query($sql);

}

需要注意的點:

后臺發貨程序在admin/order.php

需要修改的地方有: 發貨 866行 ,取消發貨 1035行 改為未發貨 3961行 退貨4132行。

本代碼只計算分成部分。自己下單部分另外。

這個代碼是按照店鋪ID分成,多商戶的。為ecshop二次開發版。無法用于原版。

調用分成: fun_fencheng_change($order,$user,$integral,1);

取消分成: fun_fencheng_change($order,$user,$integral,-1);

以上就是本文章的內容,希望對大家有所幫助

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美性受ⅹ╳╳╳黑人a性爽 | 天天夜夜草 | 奶子吧naiziba.cc免费午夜片在线观看 | 精品亚洲视频在线观看 | av在线播放免费 | 中文字幕视频在线播放 | 亚洲国产综合在线观看 | 爱看久久| 3344永久免费 | 艹男人的日日夜夜 | 亚洲一区动漫 | 欧美黄色性生活视频 | 福利在线影院 | 真人一级毛片免费 | 亚洲人成在线播放网站 | 素人视频免费观看 | 精品一区二区三区免费看 | 久久久免费观看完整版 | 91av久久 | 免费人成在线观看网站 | 中文字幕在线不卡视频 | 国产日韩久久久久69影院 | www.成人在线视频 | 日本黄色一级视频 | 99精品国产一区二区三区 | 激情久久一区二区 | av免费在线免费观看 | www.9191.com| 黄色免费不卡视频 | 久久久久性 | 黄色高清免费网站 | 美国一级黄色毛片 | 欧美一级特黄特色大片免费 | 88xx成人永久免费观看 | 永久免费黄色片 | 免费在线观看毛片视频 | 91精品国产网站 | 香蕉视频1024 | 亚洲欧美国产精品va在线观看 | 免费在线观看国产精品 | 911精品影院在线观看 |